use of com.qiniu.util.Auth in project xmall by Exrick.
the class QiniuUtil method qiniuUpload.
public static String qiniuUpload(String filePath) {
// 构造一个带指定Zone对象的配置类 zone2华南
Configuration cfg = new Configuration(Zone.zone2());
UploadManager uploadManager = new UploadManager(cfg);
String localFilePath = filePath;
// 默认不指定key的情况下,以文件内容的hash值作为文件名
String key = null;
Auth auth = Auth.create(accessKey, secretKey);
String upToken = auth.uploadToken(bucket);
try {
Response response = uploadManager.put(localFilePath, key, upToken);
// 解析上传成功的结果
DefaultPutRet putRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class);
return origin + putRet.key;
} catch (QiniuException ex) {
Response r = ex.response;
log.warn(r.toString());
try {
return r.bodyString();
} catch (QiniuException e) {
throw new XmallUploadException(e.toString());
}
}
}
use of com.qiniu.util.Auth in project paascloud-master by paascloud.
the class QiniuOssConfiguration method auth.
/**
* Auth auth.
*
* @return the auth
*/
@Bean
public Auth auth() {
Auth auth = Auth.create(paascloudProperties.getQiniu().getKey().getAccessKey(), paascloudProperties.getQiniu().getKey().getSecretKey());
log.info("Create Auth OK.");
return auth;
}
use of com.qiniu.util.Auth in project alluxio by Alluxio.
the class KodoUnderFileSystem method creatInstance.
protected static KodoUnderFileSystem creatInstance(AlluxioURI uri, UnderFileSystemConfiguration conf) {
String bucketName = UnderFileSystemUtils.getBucketName(uri);
Preconditions.checkArgument(conf.isSet(PropertyKey.KODO_ACCESS_KEY), "Property %s is required to connect to Kodo", PropertyKey.KODO_ACCESS_KEY);
Preconditions.checkArgument(conf.isSet(PropertyKey.KODO_SECRET_KEY), "Property %s is required to connect to Kodo", PropertyKey.KODO_SECRET_KEY);
Preconditions.checkArgument(conf.isSet(PropertyKey.KODO_DOWNLOAD_HOST), "Property %s is required to connect to Kodo", PropertyKey.KODO_DOWNLOAD_HOST);
Preconditions.checkArgument(conf.isSet(PropertyKey.KODO_ENDPOINT), "Property %s is required to connect to Kodo", PropertyKey.KODO_ENDPOINT);
String accessKey = conf.getString(PropertyKey.KODO_ACCESS_KEY);
String secretKey = conf.getString(PropertyKey.KODO_SECRET_KEY);
String endPoint = conf.getString(PropertyKey.KODO_ENDPOINT);
String souceHost = conf.getString(PropertyKey.KODO_DOWNLOAD_HOST);
Auth auth = Auth.create(accessKey, secretKey);
Configuration configuration = new Configuration();
OkHttpClient.Builder okHttpBuilder = initializeKodoClientConfig(conf);
OkHttpClient okHttpClient = okHttpBuilder.build();
KodoClient kodoClient = new KodoClient(auth, bucketName, souceHost, endPoint, configuration, okHttpClient);
return new KodoUnderFileSystem(uri, kodoClient, conf);
}
Aggregations