Swift:使用alamofire上载时在图像源中出现内容处置

问题描述 投票:0回答:1

我正在使用以下代码将文件成功上传到azure服务器上,该代码成功上传了文件。 (我可以在服务器上看到它)

self.manager.upload(multipartFormData: { (multipart) in

        multipart.append(fileData, withName: "file",fileName: "uploading.png" , mimeType: "image/png")

    }, to: url.description, method: .put, headers: ["x-ms-blob-type":"BlockBlob","Content-type": "multipart/form-data","Content-Disposition" :"form-data"]) { encodingResult in
        switch encodingResult {
        case .success(let upload, _, _):
            upload.response { answer in
                print("statusCode: \(String(describing: answer.response?.statusCode))")
                comp(true,"Documnet Uploaded Successfully")
            }

            upload.uploadProgress { progress in
                //call progress callback here if you need it
            }
        case .failure(let encodingError):
            print("multipart upload encodingError: \(encodingError)")
            comp(false,"Unable to Upload the documnet")
        }
}

但是

当我下载文件时(手动或通过代码)。图像无法打开。说的是>>

它可能已损坏,或使用的预览文件无法识别。

[当我在记事本中打开文件时。每行上传的图片中以下行均显示在顶部。没有这些行的文件为“ OKAY”。我不知道为什么每次都会自动添加这些。

-alamofire.boundary.5243a11a13e8a8f4

Content-Disposition:表单数据; name =“文件”; filename =“ uploading.png”

内容类型:图片/ png

请提出解决方案。

我正在使用以下代码将文件成功上传到azure服务器上,该代码成功上传了文件。 (我可以在服务器上看到它)self.manager.upload(multipartFormData:{(multipart中的multipart ....

swift alamofire image-uploading azure-blob-storage alamofire-upload
1个回答
0
投票

不是直接的答案,但是您可以参考以下一些建议。

1。在上传到天蓝色之前检查图像是否良好。

© www.soinside.com 2019 - 2024. All rights reserved.