0

我希望你做得很好。我需要完成任务,我需要将多个图像上传到服务器,并且需要在 tableView 上显示该图像的上传进度,并将相应的图像标记为已完成,哪个图像已上传到服务器并显示仍在上传的进度。

我已经在 uploadProgress 中为此实现了 Alamofire 我正在获取整个图像的上传状态进度。任何人都可以建议我或为此提供演示代码真的会对我有所帮助。下面是我的代码。

Alamofire.upload(multipartFormData: { multipartFormData in
            // import image to request
            for imageData in imagesData {
                multipartFormData.append(imageData, withName: "myImageParamName[]", fileName: "\(Date().timeIntervalSince1970).jpeg", mimeType: "image/jpeg")
            }
            for (key, value) in parameters {
                multipartFormData.append(value.data(using: String.Encoding.utf8)!, withName: key)
            }
        }, to: urlString,

            encodingCompletion: { encodingResult in
                switch encodingResult {
                case .success(let upload, _, _):

                   //HERE I'M GETTING THE PROGRESS OF MY UPLOADING FILES STATUS PROGRESS.
                    upload.uploadProgress { progress in
                        print(progress.fractionCompleted)
                    }

                    upload.responseJSON { response in
                        print("upload Success")
                    }
                case .failure(let error):
                    print("upload Failed With Error: ", error)
                }

        })
4

0 回答 0