wenweiwei 3 years ago
parent
commit
d7c7a7d828

+ 27 - 10
BFFramework/Classes/BFModules/BFUtility/PQAliOssUtil.swift

@@ -89,7 +89,7 @@ public class PQAliOssUtil: NSObject {
     ///   - localPath: <#localPath description#>
     ///   - response: <#response description#>
     /// - Returns: <#description#>
-    class public  func multipartUpload(localPath: String, response: [String: Any]?) {
+    class public  func multipartUpload(localPath: String, response: [String: Any]?,videoSource:String? = nil) {
         let accessKeyId: String = "\(response?["AccessKeyId"] ?? "")"
         let secretKeyId: String = "\(response?["AccessKeySecret"] ?? "")"
         let securityToken: String = "\(response?["SecurityToken"] ?? "")"
@@ -102,7 +102,7 @@ public class PQAliOssUtil: NSObject {
             endpoints = response?["Hosts"] as! [String]
             endpoints.append(endpoint)
         }
-        PQAliOssUtil.shared.PQOSSMultipartUpload(accessKeyId: accessKeyId, secretKeyId: secretKeyId, securityToken: securityToken, bucketName: bucketName, endpoints: endpoints, FileName: FileName, fileURL: URL(fileURLWithPath: localPath.replacingOccurrences(of: "file:///", with: "")), ossUploadID: uploadID)
+        PQAliOssUtil.shared.PQOSSMultipartUpload(accessKeyId: accessKeyId, secretKeyId: secretKeyId, securityToken: securityToken, bucketName: bucketName, endpoints: endpoints, FileName: FileName, fileURL: URL(fileURLWithPath: localPath.replacingOccurrences(of: "file:///", with: "")), ossUploadID: uploadID, videoSource: videoSource)
     }
 
     /// 重新上传
@@ -110,7 +110,7 @@ public class PQAliOssUtil: NSObject {
     ///   - response: <#response description#>
     ///   - localPath: <#localPath description#>
     /// - Returns: <#description#>
-    public  func reloadTask(response: [String: Any]?, localPath: String?) {
+    public  func reloadTask(response: [String: Any]?, localPath: String?,videoSource:String? = nil) {
         if response == nil {
             return
         }
@@ -127,7 +127,7 @@ public class PQAliOssUtil: NSObject {
             endpoints.append(endpoint)
         }
         debugPrint("取我方服务器STS 返回数据 \(String(describing: response))")
-        PQAliOssUtil.shared.PQOSSMultipartUpload(accessKeyId: accessKeyId, secretKeyId: secretKeyId, securityToken: securityToken, bucketName: bucketName, endpoints: endpoints, FileName: FileName, fileURL: URL(fileURLWithPath: (localPath ?? "").replacingOccurrences(of: "file:///", with: "")), ossUploadID: uploadID)
+        PQAliOssUtil.shared.PQOSSMultipartUpload(accessKeyId: accessKeyId, secretKeyId: secretKeyId, securityToken: securityToken, bucketName: bucketName, endpoints: endpoints, FileName: FileName, fileURL: URL(fileURLWithPath: (localPath ?? "").replacingOccurrences(of: "file:///", with: "")), ossUploadID: uploadID,videoSource: videoSource)
     }
 
     /// 分片上传
@@ -147,7 +147,7 @@ public class PQAliOssUtil: NSObject {
     ///   - width: 视频宽 isMatarialUpload = true时传
     ///   - height: 视频高 isMatarialUpload = true时传
     /// - Returns: <#description#>
-    public  func PQOSSMultipartUpload(accessKeyId: String, secretKeyId: String, securityToken: String, bucketName: String, endpoints: [String], FileName: String, fileURL: URL, ossUploadID: String, materialType: StickerType = .VIDEO, isMatarialUpload: Bool = false, contentMD5: String = "", width: CGFloat = 0, height: CGFloat = 0) -> PQAliOssUtil {
+    public  func PQOSSMultipartUpload(accessKeyId: String, secretKeyId: String, securityToken: String, bucketName: String, endpoints: [String], FileName: String, fileURL: URL, ossUploadID: String, materialType: StickerType = .VIDEO, isMatarialUpload: Bool = false, contentMD5: String = "", width: CGFloat = 0, height: CGFloat = 0,videoSource:String? = nil) -> PQAliOssUtil {
         debugPrint("上传数据 参数\n accessKeyId:\(accessKeyId)\n secretKeyId:\(secretKeyId)\n  securityToken:\(securityToken) \n bucketName:\(bucketName)\n endpoint:\(endpoints)\n FileName:\(FileName)")
         if endpoints.count <= 0 || (endpoints.first?.count ?? 0) <= 0 {
             debugPrint("endpoints 为空")
@@ -277,7 +277,11 @@ public class PQAliOssUtil: NSObject {
                     postNotification(name: cUploadSuccessKey, userInfo: ["code": 1, "objectKey": FileName, "msg": "上传成功"])
                 }
                 // 上传完成
-                PQEventTrackViewModel.baseReportUpload(businessType: .bt_up_process, objectType: .ot_up_success, pageSource: nil, remindmsg: "上传相关")
+                var extParams:Dictionary<String,Any>?
+                if videoSource != nil && (videoSource?.count ?? 0) > 0 {
+                    extParams = ["source":videoSource ?? ""]
+                }
+                PQEventTrackViewModel.baseReportUpload(businessType: .bt_up_process, objectType: .ot_up_success, pageSource: nil,extParams: extParams, remindmsg: "上传相关")
             } else {
                 debugPrint("上传失败 \(osstask.error!)")
 
@@ -296,12 +300,20 @@ public class PQAliOssUtil: NSObject {
                     }
                 }
                 // 上传失败
-                PQEventTrackViewModel.baseReportUpload(businessType: .bt_up_process, objectType: .ot_up_fail, pageSource: nil, remindmsg: "上传相关")
+                var extParams:Dictionary<String,Any>?
+                if videoSource != nil && (videoSource?.count ?? 0) > 0 {
+                    extParams = ["source":videoSource ?? ""]
+                }
+                PQEventTrackViewModel.baseReportUpload(businessType: .bt_up_process, objectType: .ot_up_fail, pageSource: nil,extParams: extParams, remindmsg: "上传相关")
             }
             return nil
         })
         // 开始上传
-        PQEventTrackViewModel.baseReportUpload(businessType: .bt_up_process, objectType: .ot_up_start, pageSource: .sp_upload_coverSelect, remindmsg: "上传相关")
+        var extParams:Dictionary<String,Any>?
+        if videoSource != nil && (videoSource?.count ?? 0) > 0 {
+            extParams = ["source":videoSource ?? ""]
+        }
+        PQEventTrackViewModel.baseReportUpload(businessType: .bt_up_process, objectType: .ot_up_start, pageSource: .sp_upload_coverSelect,extParams: extParams, remindmsg: "上传相关")
         return .shared
     }
 
@@ -326,7 +338,7 @@ public class PQAliOssUtil: NSObject {
     ///   - frameNumber: gif素材帧数 isMatarialUpload = true时传
     ///   - netResourceUrl: 网络素材地址 isMatarialUpload = true时传
     /// - Returns: <#description#>
-    public  func putObjectAsync(accessKeyId: String, secretKeyId: String, securityToken: String, bucketName: String, endpoint: [String], objectKey: String, fileURL: URL?, data: Data?, fileExtensions: String, enableBackground: Bool, materialType: StickerType = .VIDEO, isMatarialUpload: Bool = false, contentMD5: String = "", width: CGFloat = 0, height: CGFloat = 0, duration: CGFloat, frameNumber: Int, netResourceUrl: String? = nil) -> PQAliOssUtil {
+    public  func putObjectAsync(accessKeyId: String, secretKeyId: String, securityToken: String, bucketName: String, endpoint: [String], objectKey: String, fileURL: URL?, data: Data?, fileExtensions: String, enableBackground: Bool, materialType: StickerType = .VIDEO, isMatarialUpload: Bool = false, contentMD5: String = "", width: CGFloat = 0, height: CGFloat = 0, duration: CGFloat, frameNumber: Int, netResourceUrl: String? = nil,videoSource:String? = nil) -> PQAliOssUtil {
         #if DEBUG
             OSSLog.enable()
         #endif
@@ -407,7 +419,12 @@ public class PQAliOssUtil: NSObject {
                         postNotification(name: cUploadSuccessKey, userInfo: ["code": 1, "objectKey": objectKey, "msg": "上传成功"])
                     }
                     // 上传完成
-                    PQEventTrackViewModel.baseReportUpload(businessType: .bt_up_process, objectType: .ot_up_success, pageSource: nil, remindmsg: "上传相关")
+                    var extParams:Dictionary<String,Any>?
+                    if videoSource != nil && (videoSource?.count ?? 0) > 0 {
+                        extParams = ["source":videoSource ?? ""]
+                    }
+                    // 上传完成
+                    PQEventTrackViewModel.baseReportUpload(businessType: .bt_up_process, objectType: .ot_up_success, pageSource: nil,extParams: extParams, remindmsg: "上传相关")
                 } else {
                     debugPrint("上传失败 \(osstask.error!)")
                     request.callbackParam = ["code": (osstask.error! as NSError).code, "objectKey": objectKey, "msg": osstask.error?.localizedDescription ?? ""]

+ 2 - 2
BFFramework/Classes/Stuckpoint/Controller/PQStuckPointPublicController.swift

@@ -1183,11 +1183,11 @@ extension PQStuckPointPublicController {
             PQPHAssetVideoParaseUtil.exportPHAssetToMP4(phAsset: (uploadData?.asset)!, isCancelCurrentExport: true) { [weak self] _, _, filePath, _ in
                 if filePath != nil, (filePath?.count ?? 0) > 0 {
                     self?.uploadData?.localPath = filePath
-                    PQAliOssUtil.multipartUpload(localPath: self?.uploadData?.localPath ?? "", response: response)
+                    PQAliOssUtil.multipartUpload(localPath: self?.uploadData?.localPath ?? "", response: response, videoSource: "videoCompose")
                 }
             }
         } else {
-            PQAliOssUtil.multipartUpload(localPath: uploadData?.localPath ?? "", response: response)
+            PQAliOssUtil.multipartUpload(localPath: uploadData?.localPath ?? "", response: response, videoSource: "videoCompose")
         }
         PQAliOssUtil.shared.aliOssHander = { [weak self] isMatarialUpload, materialType, _, code, objectkey, _, _, _, _, _, _, _, _, _ in
             if !isMatarialUpload, materialType == .VIDEO, self?.uploadData?.videoBucketKey == objectkey {