2 コミット 052b3afe15 ... 6148435608

作者 SHA1 メッセージ 日付
  guilin 6148435608 Merge branch 'master' into master_925 1 ヶ月 前
  guilin e80f7ba837 调试 1 ヶ月 前

+ 11 - 11
app/src/main/java/com/fxy/common/AsyncFileUpload.java

@@ -196,20 +196,20 @@ public class AsyncFileUpload {
             return;
         }
 
-        // 找到最后一个斜杠的位置
-        int lastSlashIndex = ossUrl.lastIndexOf('/');
-        // 如果找到了斜杠,则从斜杠之后的位置开始切割
-        fileName = ossUrl.substring(lastSlashIndex + 1);
-
-        //斜杆开始不允许
-        int firstSlashIndex = ossUrl.indexOf('/');
-        if (firstSlashIndex==0){
-            path_prefix = ossUrl.substring(1,lastSlashIndex+ 1);
-        }else{
-            path_prefix = ossUrl.substring(0,lastSlashIndex+ 1);
+
+
+        String[] urlArr = ossUrl.split("/");
+        fileName = urlArr[urlArr.length-1];
+
+        //用户循环路径
+        for (int i = 0; i <urlArr.length -1  ; i++) {
+            if (!urlArr[i].isEmpty()){
+                path_prefix =   path_prefix.concat(urlArr[i]).concat("/");
+            }
         }
 
 
+
         if (ossService ==null){
             ossService = new OssService(mContext,path_prefix);
         }

+ 14 - 17
app/src/main/java/com/fxy/common/AsyncPictureUpload.java

@@ -342,23 +342,20 @@ public class AsyncPictureUpload {
         String ossUrl = awaitUploadList.get(num).getOssUrl();
         fileKey = awaitUploadList.get(num).getNotifyKey();
         if (!ossUrl.isEmpty()){
-            // 找到最后一个斜杠的位置
-            int lastSlashIndex = ossUrl.lastIndexOf('/');
-            // 如果找到了斜杠,则从斜杠之后的位置开始切割
-            fileName = ossUrl.substring(lastSlashIndex + 1);
-
-            //斜杆开始不允许
-            int firstSlashIndex = ossUrl.indexOf('/');
-            if (firstSlashIndex==0){
-                path_prefix = ossUrl.substring(1,lastSlashIndex+ 1);
-            }else{
-                path_prefix = ossUrl.substring(0,lastSlashIndex+ 1);
-            }
 
+            String[] urlArr = ossUrl.split("/");
+            fileName = urlArr[urlArr.length-1];
+
+            //用户循环路径
+            for (int i = 0; i <urlArr.length -1  ; i++) {
+                if (!urlArr[i].isEmpty()){
+                    path_prefix =   path_prefix.concat(urlArr[i]).concat("/");
+                }
+            }
 
 
         }else{
-            path_prefix = resourcePrefix+"/android/"+mPrefix+"/"+RxTimeTool.getYestoryDate("yyyyMMd")+"/";
+            path_prefix = resourcePrefix + "/android/" + mPrefix + "/" + RxTimeTool.getYestoryDate("yyyyMMd") + "/";
             String fileSuffix = urlPath.lastIndexOf(".")>-1 ? urlPath.substring(urlPath.lastIndexOf(".")) : "";
             fileName = UUID.randomUUID().toString() + fileSuffix;
         }
@@ -366,16 +363,16 @@ public class AsyncPictureUpload {
 
         if (resourceType.equals("tencent")){
             if (cosService==null){
-                cosService  = new CosService(mActivity.getBaseContext(),path_prefix);
+                cosService  = new CosService(mActivity.getBaseContext(), path_prefix.toString());
             }
             //new cosThread(urlPath, fileName , num).start();
-            cosService.cosUpload(urlPath, fileName , num,uploadHandler,path_prefix);
+            cosService.cosUpload(urlPath, fileName , num,uploadHandler, path_prefix.toString());
 
         }else{
             if (ossService ==null){
-                ossService = new OssService(mActivity,path_prefix);
+                ossService = new OssService(mActivity, path_prefix.toString());
             }
-            ossService.ossUpload(urlPath, fileName , num,uploadHandler,path_prefix);
+            ossService.ossUpload(urlPath, fileName , num,uploadHandler, path_prefix.toString());
             //ossService.ossUpload(urlPath, fileName , num,uploadHandler);
 
         }

+ 2 - 2
app/src/main/java/com/fxy/common/OssService.java

@@ -117,8 +117,8 @@ public class OssService {
         ClientConfiguration conf = new ClientConfiguration();
         conf.setConnectionTimeout(120 * 1000); // 连接超时,默认15秒。
         conf.setSocketTimeout(120 * 1000); // socket超时,默认15秒。
-        conf.setMaxConcurrentRequest(5); // 最大并发请求书,默认5个。
-        conf.setMaxErrorRetry(2); // 失败后最大重试次数,默认2次。
+        conf.setMaxConcurrentRequest(2); // 最大并发请求书,默认5个。
+        conf.setMaxErrorRetry(3); // 失败后最大重试次数,默认2次。
         oss = new OSSClient(mContext, endpoint, credentialProvider, conf);