com.aliyun.uploader.UserOssUploader Maven / Gradle / Ivy
package com.aliyun.uploader;
import com.aliyun.utils.CommonUtils;
import java.io.File;
public class UserOssUploader extends BaseOssUploader {
private static final String NAME = "User OSS Uploader";
private String regionId;
private String bucket;
private String key;
private String ak;
private String sk;
private String appId;
private String packageVersion;
private String edasEndpoint;
private String generateKey() {
String ptn = CommonUtils.isEmpty(this.key) ? "{region_id}/{app_id}/{version}" : this.key;
return ptn.replaceAll("\\{region_id}", regionId)
.replaceAll("\\{app_id}", appId)
.replaceAll("\\{version}", packageVersion);
}
UserOssUploader(
String edasEndpoint, String regionId, String bucket, String key,
String ak, String sk, String appId, String packageVersion) {
this.edasEndpoint = edasEndpoint;
this.regionId = regionId;
this.bucket = bucket;
this.key = key;
this.ak = ak;
this.sk = sk;
this.appId = appId;
this.packageVersion = packageVersion;
}
@Override
public String getName() {
return NAME;
}
@Override
public String upload(File file) throws Exception {
return doUpload(edasEndpoint, this.regionId, this.bucket, generateKey(), file, this.ak, this.sk, null);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy