| | |
| | | */ |
| | | public class QiniuCloudStorageStrategy extends AbstractCloudStorageStrategy { |
| | | |
| | | private final UploadManager uploadManager; |
| | | private final BucketManager bucketManager; |
| | | private final String token; |
| | | private UploadManager uploadManager; |
| | | private BucketManager bucketManager; |
| | | private String token; |
| | | |
| | | public QiniuCloudStorageStrategy(CloudStorageProperties cloudStorageProperties) { |
| | | @Override |
| | | public void init(CloudStorageProperties cloudStorageProperties) { |
| | | properties = cloudStorageProperties; |
| | | try { |
| | | Configuration config = new Configuration(getRegion(properties.getRegion())); |
| | |
| | | bucketManager.createBucket(bucketName, properties.getRegion()); |
| | | } |
| | | } catch (Exception e) { |
| | | throw new IllegalArgumentException("七牛云存储配置错误! 请检查系统配置!"); |
| | | throw new OssException("七牛云存储配置错误! 请检查系统配置:[" + e.getMessage() + "]"); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | bucketManager.createBucket(bucketName, properties.getRegion()); |
| | | } catch (Exception e) { |
| | | throw new OssException("创建Bucket失败, 请核对七牛云配置信息"); |
| | | throw new OssException("创建Bucket失败, 请核对七牛云配置信息:[" + e.getMessage() + "]"); |
| | | } |
| | | } |
| | | |
| | |
| | | throw new RuntimeException("上传七牛出错:" + res.toString()); |
| | | } |
| | | } catch (Exception e) { |
| | | throw new OssException("上传文件失败,请核对七牛配置信息"); |
| | | throw new OssException("上传文件失败,请核对七牛配置信息:[" + e.getMessage() + "]"); |
| | | } |
| | | return new UploadResult().setUrl(getEndpointLink() + "/" + path).setFilename(path); |
| | | } |