七色猫视频 v9.9.9版本的 MD5 值为:6e3740f68cd7a75ec951b5f356e1fd2c
以下内容为反编译后的 OssService.java 源代码,内容仅作参考
package com.yz.baselib.net.oss;
import android.content.Context;
import android.graphics.BitmapFactory;
import android.media.MediaMetadataRetriever;
import android.os.Looper;
import com.alibaba.sdk.android.oss.ClientConfiguration;
import com.alibaba.sdk.android.oss.ClientException;
import com.alibaba.sdk.android.oss.OSS;
import com.alibaba.sdk.android.oss.OSSClient;
import com.alibaba.sdk.android.oss.ServiceException;
import com.alibaba.sdk.android.oss.callback.OSSCompletedCallback;
import com.alibaba.sdk.android.oss.callback.OSSProgressCallback;
import com.alibaba.sdk.android.oss.common.auth.OSSCustomSignerCredentialProvider;
import com.alibaba.sdk.android.oss.common.utils.HttpHeaders;
import com.alibaba.sdk.android.oss.common.utils.OSSUtils;
import com.alibaba.sdk.android.oss.internal.OSSAsyncTask;
import com.alibaba.sdk.android.oss.model.DeleteObjectRequest;
import com.alibaba.sdk.android.oss.model.DeleteObjectResult;
import com.alibaba.sdk.android.oss.model.ObjectMetadata;
import com.alibaba.sdk.android.oss.model.PutObjectRequest;
import com.alibaba.sdk.android.oss.model.PutObjectResult;
import com.blankj.utilcode.util.ToastUtils;
import com.blankj.utilcode.util.Utils;
import com.google.android.exoplayer.DefaultLoadControl;
import com.yz.baselib.base.UserManager;
import com.yz.baselib.log.JyLogger;
import com.yz.baselib.net.oss.OssService;
import com.yz.baselib.net.oss.entity.UploadPicBean;
import com.yz.baselib.utils.LogUtils;
import io.reactivex.Completable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Action;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
public class OssService {
private static final int MAX_RETRY_COUNT = 1;
public static final int TYPE_AVATAR = 1;
public static final int TYPE_IM = 4;
public static final int TYPE_USER_PIC = 2;
private String bucketIM;
private picResultCallback callback;
private OSS mOSS;
int number;
private OSS oss;
private OSSAsyncTask putTask;
private int type;
public static final String OssPrefix = "postbar/android/" + UserManager.getUserId() + "/";
public static final String RegisterAvatarPrefix = "avatar/android/" + UserManager.getUserId() + "/";
public static final String UserPicPrefix = "user-pic/android/" + UserManager.getUserId() + "/";
public static final String ReportOssPrefix = "report/android/" + UserManager.getUserId() + "/";
Map<String, String> success = new LinkedHashMap();
List<String> failure = new ArrayList();
private String bucket = "mm-anchor";
private String path = "http://oss-cn-hangzhou.aliyuncs.com";
private String OssIMPrefix = "im/" + UserManager.getUserId() + "/";
private Map<String, OSSAsyncTask> mAsyncTaskMap = new ConcurrentHashMap();
private AtomicInteger mPutTotalCount = new AtomicInteger(0);
private AtomicInteger mPutSuccessCount = new AtomicInteger(0);
private AtomicInteger mPutRetryCount = new AtomicInteger(0);
private Map<String, String> mSuccessMap = new ConcurrentHashMap();
private List<String> mFailures = Collections.synchronizedList(new ArrayList());
private Map<String, long[]> mProgressMap = new ConcurrentHashMap();
private Map<String, ExtraInfo> mExtraInfoMap = new ConcurrentHashMap();
public interface Callback {
public final class CC {
public static boolean $default$isNeedProgress(Callback _this) {
return false;
}
public static void $default$onError(Callback _this) {
}
public static void $default$onProgress(Callback _this, float f) {
}
}
boolean isNeedProgress();
void onError();
void onProgress(float f);
void onSuccess(List<ObjectBean> list);
}
public interface picResultCallback {
void onError();
void onProgress(float f);
void onSuccess(PutObjectResult putObjectResult, String str, String str2, List<UploadPicBean> list);
}
public OssService(picResultCallback picresultcallback, Context context) {
OSSCustomSignerCredentialProvider oSSCustomSignerCredentialProvider = new OSSCustomSignerCredentialProvider() {
@Override
public String signContent(String str) {
return OSSUtils.sign(OssConfig.AccessKeyId, OssConfig.AccessKeySecret, str);
}
};
ClientConfiguration clientConfiguration = new ClientConfiguration();
clientConfiguration.setConnectionTimeout(DefaultLoadControl.DEFAULT_HIGH_WATERMARK_MS);
clientConfiguration.setSocketTimeout(DefaultLoadControl.DEFAULT_HIGH_WATERMARK_MS);
clientConfiguration.setMaxConcurrentRequest(5);
clientConfiguration.setMaxErrorRetry(2);
this.oss = new OSSClient(Utils.getApp().getApplicationContext(), "http://oss-cn-hangzhou.aliyuncs.com", oSSCustomSignerCredentialProvider, clientConfiguration);
this.callback = picresultcallback;
}
public OssService(int i, Context context) {
OSSCustomSignerCredentialProvider oSSCustomSignerCredentialProvider = new OSSCustomSignerCredentialProvider() {
@Override
public String signContent(String str) {
return OSSUtils.sign(OssConfig.AccessKeyId, OssConfig.AccessKeySecret, str);
}
};
ClientConfiguration clientConfiguration = new ClientConfiguration();
clientConfiguration.setConnectionTimeout(DefaultLoadControl.DEFAULT_LOW_WATERMARK_MS);
clientConfiguration.setSocketTimeout(DefaultLoadControl.DEFAULT_LOW_WATERMARK_MS);
clientConfiguration.setMaxConcurrentRequest(9);
clientConfiguration.setMaxErrorRetry(2);
this.mOSS = new OSSClient(Utils.getApp().getApplicationContext(), "http://oss-cn-hangzhou.aliyuncs.com", oSSCustomSignerCredentialProvider, clientConfiguration);
setBucketName(i);
this.type = i;
}
public static int[] getImageWidthHeight(String str) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(str, options);
return new int[]{options.outWidth, options.outHeight};
}
private void setBucketName(int i) {
if (i != 4) {
return;
}
this.bucketIM = "mm-anchor";
}
public void asyncPut(final String str) {
File file = new File(str);
if (!file.exists()) {
LogUtils.e("asyncPut", "FileNotExist");
return;
}
final String generateObjectKeyFromFile = generateObjectKeyFromFile(file);
PutObjectRequest putObjectRequest = new PutObjectRequest(this.bucket, generateObjectKeyFromFile, str);
putObjectRequest.setProgressCallback(new OSSProgressCallback<PutObjectRequest>() {
@Override
public void onProgress(PutObjectRequest putObjectRequest2, long j, long j2) {
picResultCallback picresultcallback = OssService.this.callback;
picresultcallback.onProgress(((float) j) / Float.parseFloat(j2 + ""));
}
});
this.putTask = this.oss.asyncPutObject(putObjectRequest, new OSSCompletedCallback<PutObjectRequest, PutObjectResult>() {
@Override
public void onSuccess(PutObjectRequest putObjectRequest2, PutObjectResult putObjectResult) {
OssService.this.callback.onSuccess(putObjectResult, str, generateObjectKeyFromFile, null);
LogUtils.d("PutObject", "UploadSuccess");
LogUtils.d(HttpHeaders.ETAG, putObjectResult.getETag());
LogUtils.d("RequestId", putObjectResult.getRequestId());
}
@Override
public void onFailure(PutObjectRequest putObjectRequest2, ClientException clientException, ServiceException serviceException) {
if (clientException != null) {
clientException.printStackTrace();
}
if (serviceException != null) {
LogUtils.e("ErrorCode", serviceException.getErrorCode());
LogUtils.e("RequestId", serviceException.getRequestId());
LogUtils.e("HostId", serviceException.getHostId());
LogUtils.e("RawMessage", serviceException.getRawMessage());
}
OssService.this.callback.onError();
}
});
}
public void asyncPut(final List<String> list, String str) {
this.number = 0;
this.success.clear();
this.failure.clear();
for (String str2 : list) {
File file = new File(str2);
String str3 = System.currentTimeMillis() + "";
this.success.put(file.getPath() + str3, "");
ObjectMetadata objectMetadata = new ObjectMetadata();
objectMetadata.addUserMetadata("time", str3);
this.oss.asyncPutObject(new PutObjectRequest(this.bucket, str + file.getName(), file.getPath(), objectMetadata), new OSSCompletedCallback<PutObjectRequest, PutObjectResult>() {
@Override
public void onSuccess(PutObjectRequest putObjectRequest, PutObjectResult putObjectResult) {
OssService.this.number++;
ObjectMetadata metadata = putObjectRequest.getMetadata();
OssService.this.success.put(putObjectRequest.getUploadFilePath() + metadata.getUserMetadata().get("time"), putObjectRequest.getObjectKey());
if (OssService.this.number == list.size()) {
if (OssService.this.success.size() == list.size()) {
ArrayList arrayList = new ArrayList();
for (Map.Entry<String, String> entry : OssService.this.success.entrySet()) {
UploadPicBean uploadPicBean = new UploadPicBean();
uploadPicBean.setPic(entry.getValue());
int[] imageWidthHeight = OssService.getImageWidthHeight(entry.getKey());
uploadPicBean.setWidth(imageWidthHeight[0]);
uploadPicBean.setHeight(imageWidthHeight[1]);
arrayList.add(uploadPicBean);
}
OssService.this.callback.onSuccess(putObjectResult, null, null, arrayList);
} else {
for (Map.Entry<String, String> entry2 : OssService.this.success.entrySet()) {
OssService.this.asyncDelete(entry2.getValue());
}
OssService.this.callback.onError();
}
}
LogUtils.d("PutObject", "UploadSuccess");
LogUtils.d(HttpHeaders.ETAG, putObjectResult.getETag());
LogUtils.d("RequestId", putObjectResult.getRequestId());
}
@Override
public void onFailure(PutObjectRequest putObjectRequest, ClientException clientException, ServiceException serviceException) {
if (clientException != null) {
clientException.printStackTrace();
}
if (serviceException != null) {
LogUtils.e("ErrorCode", serviceException.getErrorCode());
LogUtils.e("RequestId", serviceException.getRequestId());
LogUtils.e("HostId", serviceException.getHostId());
LogUtils.e("RawMessage", serviceException.getRawMessage());
}
OssService.this.number++;
OssService.this.failure.add(putObjectRequest.getMetadata().getUserMetadata().get("filePath"));
if (OssService.this.number == list.size()) {
for (Map.Entry<String, String> entry : OssService.this.success.entrySet()) {
OssService.this.asyncDelete(entry.getValue());
}
OssService.this.callback.onError();
}
}
});
}
}
public void asyncPut(String str, Callback callback) {
File file = new File(str);
if (!file.exists()) {
com.blankj.utilcode.util.LogUtils.e("asyncPut", "FileNotExist");
return;
}
String generateObjectKeyFromFile = generateObjectKeyFromFile(file);
PutObjectRequest putObjectRequest = new PutObjectRequest(getBucketName(this.type), generateObjectKeyFromFile, str);
putObjectRequest.setProgressCallback(new AnonymousClass6(callback));
this.mAsyncTaskMap.put(generateObjectKeyFromFile, this.mOSS.asyncPutObject(putObjectRequest, new AnonymousClass7(callback)));
}
class AnonymousClass6 implements OSSProgressCallback<PutObjectRequest> {
final Callback val$callback;
AnonymousClass6(Callback callback) {
this.val$callback = callback;
}
@Override
public void onProgress(PutObjectRequest putObjectRequest, long j, long j2) {
Callback callback = this.val$callback;
if (callback == null || !callback.isNeedProgress()) {
return;
}
final float f = ((((float) j) * 1.0f) / ((float) j2)) * 1.0f;
if (Looper.myLooper() == Looper.getMainLooper()) {
this.val$callback.onProgress(f);
return;
}
final Callback callback2 = this.val$callback;
Completable.fromAction(new Action() {
@Override
public final void run() {
OssService.Callback.this.onProgress(f);
}
}).subscribeOn(AndroidSchedulers.mainThread()).subscribe();
}
}
class AnonymousClass7 implements OSSCompletedCallback<PutObjectRequest, PutObjectResult> {
final Callback val$callback;
AnonymousClass7(Callback callback) {
this.val$callback = callback;
}
@Override
public void onSuccess(PutObjectRequest putObjectRequest, PutObjectResult putObjectResult) {
OssService.this.mAsyncTaskMap.remove(putObjectRequest.getObjectKey());
if (this.val$callback != null) {
final ArrayList arrayList = new ArrayList();
ObjectBean objectBean = new ObjectBean();
objectBean.setObjectName(putObjectRequest.getObjectKey());
arrayList.add(objectBean);
if (Looper.myLooper() == Looper.getMainLooper()) {
this.val$callback.onSuccess(arrayList);
} else {
final Callback callback = this.val$callback;
Completable.fromAction(new Action() {
@Override
public final void run() {
OssService.Callback.this.onSuccess(arrayList);
}
}).subscribeOn(AndroidSchedulers.mainThread()).subscribe();
}
}
com.blankj.utilcode.util.LogUtils.d("PutObject", "UploadSuccess");
com.blankj.utilcode.util.LogUtils.d(HttpHeaders.ETAG, putObjectResult.getETag());
com.blankj.utilcode.util.LogUtils.d("RequestId", putObjectResult.getRequestId());
}
@Override
public void onFailure(PutObjectRequest putObjectRequest, ClientException clientException, ServiceException serviceException) {
OssService.this.mAsyncTaskMap.remove(putObjectRequest.getObjectKey());
if (clientException != null) {
clientException.printStackTrace();
}
if (serviceException != null) {
com.blankj.utilcode.util.LogUtils.e("ErrorCode", serviceException.getErrorCode());
com.blankj.utilcode.util.LogUtils.e("RequestId", serviceException.getRequestId());
com.blankj.utilcode.util.LogUtils.e("HostId", serviceException.getHostId());
com.blankj.utilcode.util.LogUtils.e("RawMessage", serviceException.getRawMessage());
}
if (this.val$callback != null) {
if (Looper.myLooper() == Looper.getMainLooper()) {
this.val$callback.onError();
return;
}
final Callback callback = this.val$callback;
Completable.fromAction(new Action() {
@Override
public final void run() {
OssService.Callback.this.onError();
}
}).subscribeOn(AndroidSchedulers.mainThread()).subscribe();
}
}
}
public <T> void asyncMultiPut(List<T> list, Callback callback) {
int i;
boolean z;
File file;
File file2;
Iterator<T> it = list.iterator();
do {
if (!it.hasNext()) {
z = false;
break;
}
T next = it.next();
if (next instanceof File) {
file2 = (File) next;
} else if (next instanceof String) {
file2 = new File((String) next);
} else {
JyLogger.write("asyncMultiPut 只支持file和filePath");
throw new IllegalArgumentException("只支持file和filePath");
}
if (!file2.exists()) {
break;
}
} while (file2.isFile());
JyLogger.write("asyncMultiPut file exists = " + file2.exists());
JyLogger.write("asyncMultiPut is file = " + file2.isFile());
z = true;
if (z) {
ToastUtils.showShort("包含不存在的文件或非法的文件,请重新上传");
JyLogger.write("asyncMultiPut 包含不存在的文件或非法的文件,请重新上传");
if (callback != null) {
callback.onError();
return;
}
return;
}
this.mPutSuccessCount.set(0);
this.mPutTotalCount.set(0);
int size = list.size();
for (i = 0; i < size; i++) {
T t = list.get(i);
if (t instanceof File) {
file = (File) t;
} else if (t instanceof String) {
file = new File((String) t);
} else {
JyLogger.write("asyncMultiPut 包含不存在的文件或非法的文件,请重新上传 2");
throw new IllegalArgumentException("只支持file和filePath");
}
asyncFile(i, size, file, callback);
}
}
private void asyncFile(int i, final int i2, File file, final Callback callback) {
String absolutePath = file.getAbsolutePath();
int[] imageWidthHeight = getImageWidthHeight(absolutePath);
JyLogger.write("asyncFile imageSize = " + imageWidthHeight[0] + "_" + imageWidthHeight[1]);
if (imageWidthHeight[0] == -1 && imageWidthHeight[1] == -1) {
imageWidthHeight = getVideoSize(file.getAbsolutePath());
JyLogger.write("asyncFile videoSize = " + imageWidthHeight[0] + "_" + imageWidthHeight[1]);
}
if (!this.mExtraInfoMap.containsKey(absolutePath)) {
this.mExtraInfoMap.put(absolutePath, new ExtraInfo(imageWidthHeight[0], imageWidthHeight[1], i));
}
String generateObjectKeyFromFile = generateObjectKeyFromFile(file, imageWidthHeight[0], imageWidthHeight[1]);
JyLogger.write("asyncFile objectKey = " + generateObjectKeyFromFile);
PutObjectRequest putObjectRequest = new PutObjectRequest(getBucketName(this.type), generateObjectKeyFromFile, absolutePath);
putObjectRequest.setProgressCallback(new OSSProgressCallback() {
@Override
public final void onProgress(Object obj, long j, long j2) {
OssService.this.m3288lambda$asyncFile$1$comyzbaselibnetossOssService(callback, i2, (PutObjectRequest) obj, j, j2);
}
});
com.blankj.utilcode.util.LogUtils.d("测试上传=上传阿里云开始");
this.mAsyncTaskMap.put(generateObjectKeyFromFile, this.mOSS.asyncPutObject(putObjectRequest, new OSSCompletedCallback<PutObjectRequest, PutObjectResult>() {
@Override
public void onSuccess(PutObjectRequest putObjectRequest2, PutObjectResult putObjectResult) {
com.blankj.utilcode.util.LogUtils.d("测试上传=上传阿里云成功的回调");
String objectKey = putObjectRequest2.getObjectKey();
OssService.this.mAsyncTaskMap.remove(objectKey);
OssService.this.mSuccessMap.put(putObjectRequest2.getUploadFilePath(), objectKey);
int incrementAndGet = OssService.this.mPutSuccessCount.incrementAndGet();
int incrementAndGet2 = OssService.this.mPutTotalCount.incrementAndGet();
JyLogger.write("asyncFile 上传阿里云成功的回调");
JyLogger.write("asyncFile 上传阿里云成功的回调 mPutTotalCount = " + incrementAndGet2 + "-> size = " + i2 + "-> mPutSuccessCount = " + incrementAndGet);
com.blankj.utilcode.util.LogUtils.d("测试上传=上传阿里云成功mPutTotalCount=" + incrementAndGet2 + "->size=" + i2 + "->mPutSuccessCount=" + incrementAndGet);
int i3 = i2;
if (incrementAndGet2 == i3) {
if (incrementAndGet == i3) {
OssService.this.multiPutCompleted(callback);
} else {
OssService.this.retryAsyncPut(callback);
}
}
}
@Override
public void onFailure(PutObjectRequest putObjectRequest2, ClientException clientException, ServiceException serviceException) {
JyLogger.write("asyncFile 上传oss失败,clientException = " + clientException.getMessage() + ", serviceException = " + serviceException.getMessage());
com.blankj.utilcode.util.LogUtils.d("测试上传=上传阿里云失败的回调");
OssService.this.mAsyncTaskMap.remove(putObjectRequest2.getObjectKey());
OssService.this.mFailures.add(putObjectRequest2.getUploadFilePath());
JyLogger.write("asyncFile 上传oss失败,failed file path" + putObjectRequest2.getUploadFilePath());
int incrementAndGet = OssService.this.mPutTotalCount.incrementAndGet();
com.blankj.utilcode.util.LogUtils.d("测试上传=上传阿里云失败->mPutTotalCount=" + OssService.this.mPutTotalCount + "->size=" + i2 + "->clientException=" + clientException.getMessage() + "->serviceException->" + serviceException.getMessage());
StringBuilder sb = new StringBuilder();
sb.append("asyncFile 上传oss失败,mPutTotalCount=");
sb.append(OssService.this.mPutTotalCount);
sb.append("->size=");
sb.append(i2);
JyLogger.write(sb.toString());
if (incrementAndGet == i2) {
JyLogger.write("asyncFile 上传oss失败,重试");
OssService.this.retryAsyncPut(callback);
}
}
}));
}
public void m3288lambda$asyncFile$1$comyzbaselibnetossOssService(final Callback callback, int i, PutObjectRequest putObjectRequest, long j, long j2) {
if (callback == null || !callback.isNeedProgress()) {
return;
}
this.mProgressMap.put(putObjectRequest.getUploadFilePath(), new long[]{j, j2});
if (this.mProgressMap.size() == i) {
long j3 = 0;
long j4 = 0;
for (Map.Entry<String, long[]> entry : this.mProgressMap.entrySet()) {
long[] value = entry.getValue();
j3 += value[0];
j4 += value[1];
}
float f = ((((float) j3) * 1.0f) / ((float) j4)) * 1.0f;
final float f2 = f <= 1.0f ? f : 1.0f;
if (Looper.myLooper() == Looper.getMainLooper()) {
callback.onProgress(f2);
} else {
Completable.fromAction(new Action() {
@Override
public final void run() {
OssService.Callback.this.onProgress(f2);
}
}).subscribeOn(AndroidSchedulers.mainThread()).subscribe();
}
}
}
public void multiPutCompleted(final Callback callback) {
if (callback != null) {
if (this.mSuccessMap.isEmpty()) {
JyLogger.write("multiPutCompleted mSuccessMap isEmpty");
if (Looper.myLooper() == Looper.getMainLooper()) {
callback.onError();
} else {
Completable.fromAction(new Action() {
@Override
public final void run() {
OssService.Callback.this.onError();
}
}).subscribeOn(AndroidSchedulers.mainThread()).subscribe();
}
} else {
final ArrayList arrayList = new ArrayList();
for (Map.Entry<String, String> entry : this.mSuccessMap.entrySet()) {
String key = entry.getKey();
ExtraInfo extraInfo = this.mExtraInfoMap.get(key);
ObjectBean objectBean = new ObjectBean();
objectBean.setObjectName(entry.getValue());
objectBean.setFilePath(key);
objectBean.setWidth(extraInfo.getWidth());
objectBean.setHeight(extraInfo.getHeight());
objectBean.setIndex(extraInfo.getIndex());
arrayList.add(objectBean);
}
Collections.sort(arrayList);
if (Looper.myLooper() == Looper.getMainLooper()) {
callback.onSuccess(arrayList);
} else {
Completable.fromAction(new Action() {
@Override
public final void run() {
OssService.Callback.this.onSuccess(arrayList);
}
}).subscribeOn(AndroidSchedulers.mainThread()).subscribe();
}
}
}
resetAllData();
}
public void retryAsyncPut(final Callback callback) {
if (this.mPutRetryCount.incrementAndGet() - 1 >= 1) {
multiPutCompleted(callback);
JyLogger.write("retryAsyncPut multiPutCompleted");
} else if (Looper.myLooper() == Looper.getMainLooper()) {
m3289lambda$retryAsyncPut$4$comyzbaselibnetossOssService(callback);
} else {
Completable.fromAction(new Action() {
@Override
public final void run() {
OssService.this.m3289lambda$retryAsyncPut$4$comyzbaselibnetossOssService(callback);
}
}).subscribeOn(AndroidSchedulers.mainThread()).subscribe();
}
}
public void m3289lambda$retryAsyncPut$4$comyzbaselibnetossOssService(Callback callback) {
ArrayList arrayList = new ArrayList(this.mFailures);
this.mFailures.clear();
asyncMultiPut(arrayList, callback);
}
private void resetAllData() {
this.mPutRetryCount.set(0);
this.mPutSuccessCount.set(0);
this.mPutTotalCount.set(0);
this.mSuccessMap.clear();
this.mProgressMap.clear();
this.mFailures.clear();
this.mExtraInfoMap.clear();
}
public void cancelAllTask() {
Iterator<Map.Entry<String, OSSAsyncTask>> it = this.mAsyncTaskMap.entrySet().iterator();
while (it.hasNext()) {
it.next().getValue().cancel();
it.remove();
}
resetAllData();
}
private static int[] getVideoSize(String str) {
MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
mediaMetadataRetriever.setDataSource(str);
return new int[]{parseInt(mediaMetadataRetriever.extractMetadata(18)), parseInt(mediaMetadataRetriever.extractMetadata(19))};
}
private String generateObjectKeyFromFile(File file) {
return getBucketPrefix(this.type) + file.getName();
}
private String generateObjectKeyFromFile(File file, int i, int i2) {
String[] split;
String name = file.getName();
if (name.split("\\.").length == 2) {
name = split[0] + "_" + i + "x" + i2 + "." + split[1];
}
return getBucketPrefix(this.type) + name;
}
private String getBucketPrefix(int i) {
if (i != 1) {
if (i != 2) {
if (i == 4) {
return this.OssIMPrefix;
}
return OssPrefix;
}
return UserPicPrefix;
}
return RegisterAvatarPrefix;
}
private String getBucketName(int i) {
if (i == 4) {
return this.bucketIM;
}
return this.bucket;
}
public void asyncDelete(String str) {
this.oss.asyncDeleteObject(new DeleteObjectRequest("mm-anchor", str), new OSSCompletedCallback<DeleteObjectRequest, DeleteObjectResult>() {
@Override
public void onSuccess(DeleteObjectRequest deleteObjectRequest, DeleteObjectResult deleteObjectResult) {
LogUtils.d("asyncDelete", "success!");
}
@Override
public void onFailure(DeleteObjectRequest deleteObjectRequest, ClientException clientException, ServiceException serviceException) {
if (clientException != null) {
clientException.printStackTrace();
}
if (serviceException != null) {
LogUtils.e("ErrorCode", serviceException.getErrorCode());
LogUtils.e("RequestId", serviceException.getRequestId());
LogUtils.e("HostId", serviceException.getHostId());
LogUtils.e("RawMessage", serviceException.getRawMessage());
}
}
});
}
public void putSingleInterept() {
OSSAsyncTask oSSAsyncTask = this.putTask;
if (oSSAsyncTask != null) {
oSSAsyncTask.cancel();
}
}
public static class ObjectBean implements Comparable<ObjectBean> {
private String filePath;
private int height;
private int index;
private String objectName;
private int width;
public int getIndex() {
return this.index;
}
public void setIndex(int i) {
this.index = i;
}
public String getFilePath() {
return this.filePath;
}
public void setFilePath(String str) {
this.filePath = str;
}
public String getObjectName() {
return this.objectName;
}
public void setObjectName(String str) {
this.objectName = str;
}
public int getHeight() {
return this.height;
}
public void setHeight(int i) {
this.height = i;
}
public int getWidth() {
return this.width;
}
public void setWidth(int i) {
this.width = i;
}
@Override
public int compareTo(ObjectBean objectBean) {
return getIndex() - objectBean.getIndex();
}
}
public static class ExtraInfo {
private int height;
private int index;
private int width;
public ExtraInfo(int i, int i2, int i3) {
this.height = i2;
this.width = i;
this.index = i3;
}
public int getHeight() {
return this.height;
}
public void setHeight(int i) {
this.height = i;
}
public int getWidth() {
return this.width;
}
public void setWidth(int i) {
this.width = i;
}
public int getIndex() {
return this.index;
}
public void setIndex(int i) {
this.index = i;
}
}
public static int parseInt(String str) {
try {
return Integer.parseInt(str);
} catch (NullPointerException | NumberFormatException e) {
e.printStackTrace();
return 0;
}
}
}