use of com.zyd.blog.file.ApiClient in project OneBlog by zhangyd-c.
the class BaseFileUploader method getApiClient.
ApiClient getApiClient(String uploadType) {
SysConfigService configService = SpringContextHolder.getBean(SysConfigService.class);
Map<String, Object> config = configService.getConfigs();
String storageType = null;
if (null == config || StringUtils.isEmpty((storageType = (String) config.get(ConfigKeyEnum.STORAGE_TYPE.getKey())))) {
throw new ZhydException("[文件服务]当前系统暂未配置文件服务相关的内容!");
}
ApiClient res = null;
switch(storageType) {
case "local":
String localFileUrl = (String) config.get(ConfigKeyEnum.LOCAL_FILE_URL.getKey()), localFilePath = (String) config.get(ConfigKeyEnum.LOCAL_FILE_PATH.getKey());
res = new LocalApiClient().init(localFileUrl, localFilePath, uploadType);
break;
case "qiniu":
String accessKey = (String) config.get(ConfigKeyEnum.QINIU_ACCESS_KEY.getKey()), secretKey = (String) config.get(ConfigKeyEnum.QINIU_SECRET_KEY.getKey()), qiniuBucketName = (String) config.get(ConfigKeyEnum.QINIU_BUCKET_NAME.getKey()), baseUrl = (String) config.get(ConfigKeyEnum.QINIU_BASE_PATH.getKey());
res = new QiniuApiClient().init(accessKey, secretKey, qiniuBucketName, baseUrl, uploadType);
break;
case "aliyun":
String endpoint = (String) config.get(ConfigKeyEnum.ALIYUN_ENDPOINT.getKey()), accessKeyId = (String) config.get(ConfigKeyEnum.ALIYUN_ACCESS_KEY.getKey()), accessKeySecret = (String) config.get(ConfigKeyEnum.ALIYUN_ACCESS_KEY_SECRET.getKey()), url = (String) config.get(ConfigKeyEnum.ALIYUN_FILE_URL.getKey()), aliYunBucketName = (String) config.get(ConfigKeyEnum.ALIYUN_BUCKET_NAME.getKey());
res = new AliyunOssApiClient().init(endpoint, accessKeyId, accessKeySecret, url, aliYunBucketName, uploadType);
break;
case "youpaiyun":
break;
default:
break;
}
if (null == res) {
throw new GlobalFileException("[文件服务]当前系统暂未配置文件服务相关的内容!");
}
return res;
}
use of com.zyd.blog.file.ApiClient in project OneBlog by zhangyd-c.
the class GlobalFileUploader method upload.
@Override
public VirtualFile upload(InputStream is, String uploadType, String imageUrl, boolean save) {
ApiClient apiClient = this.getApiClient(uploadType);
VirtualFile virtualFile = apiClient.uploadImg(is, imageUrl);
return this.saveFile(virtualFile, save, uploadType);
}
use of com.zyd.blog.file.ApiClient in project OneBlog by zhangyd-c.
the class GlobalFileUploader method upload.
@Override
public VirtualFile upload(MultipartFile file, String uploadType, boolean save) {
ApiClient apiClient = this.getApiClient(uploadType);
VirtualFile virtualFile = apiClient.uploadImg(file);
return this.saveFile(virtualFile, save, uploadType);
}
use of com.zyd.blog.file.ApiClient in project OneBlog by zhangyd-c.
the class GlobalFileUploader method upload.
@Override
public VirtualFile upload(File file, String uploadType, boolean save) {
ApiClient apiClient = this.getApiClient(uploadType);
VirtualFile virtualFile = apiClient.uploadImg(file);
return this.saveFile(virtualFile, save, uploadType);
}
Aggregations