云顶彩票 v1.0.0版本的 MD5 值为:63ba5d5275adbaa5b51a7abfd0af75f7
以下内容为反编译后的 FormUploader.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) {
this.signature = signatureListener.getSignature(this.policy + "&");
} else {
throw new RuntimeException("apiKey 和 signatureListener 不能同时为null");
}
}
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();
}
}
}
}