正在查看: moonshot.企业版 v5.53.33 应用的 FormUploader.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: moonshot.企业版 v5.53.33 应用的 FormUploader.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package cn.bmob.v3.datatype.up;
import cn.bmob.v3.exception.BmobException;
import java.io.File;
import java.io.IOException;
import java.util.Map;
public class FormUploader implements Runnable {
private String apiKey;
private String bucket;
private UploadClient client;
private UpCompleteListener completeListener;
private File file;
private Map<String, Object> params;
private String policy;
private UpProgressListener progressListener;
private int retryTime;
private String signature;
private SignatureListener signatureListener;
public FormUploader(UploadClient uploadClient, File file, Map<String, Object> map, String str, SignatureListener signatureListener, UpCompleteListener upCompleteListener, UpProgressListener upProgressListener) {
this.client = uploadClient;
this.file = file;
this.bucket = (String) map.get(Params.BUCKET);
this.params = map;
this.apiKey = str;
this.signatureListener = signatureListener;
this.completeListener = upCompleteListener;
this.progressListener = upProgressListener;
}
@Override
public void run() {
String str = (String) this.params.get(Params.SAVE_KEY);
String str2 = (String) this.params.remove("path");
if (str == null && str2 != null) {
this.params.put(Params.SAVE_KEY, str2);
}
String policy = UpYunUtils.getPolicy(this.params);
this.policy = policy;
String str3 = this.apiKey;
if (str3 != null) {
this.signature = UpYunUtils.getSignature(policy, str3);
} else {
SignatureListener signatureListener = this.signatureListener;
if (signatureListener == null) {
throw new RuntimeException("apiKey 和 signatureListener 不能同时为null");
}
this.signature = signatureListener.getSignature(this.policy + "&");
}
try {
this.completeListener.onComplete(true, this.client.fromUpLoad(this.file, "http://v0.api.upyun.com/" + this.bucket, this.policy, this.signature, this.progressListener));
} catch (BmobException | IOException e) {
int i = this.retryTime + 1;
this.retryTime = i;
boolean z = i > 2;
boolean z2 = (e instanceof BmobException) && ((BmobException) e).getErrorCode() / 100 != 5;
if (z || z2) {
this.completeListener.onComplete(false, e.toString());
} else {
run();
}
}
}
}