OGeek|极客世界-中国程序员成长平台

标题: ios - 应用程序在 swift 3 的 AWS S3 存储桶中上传图像时崩溃 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 18:54
标题: ios - 应用程序在 swift 3 的 AWS S3 存储桶中上传图像时崩溃

在我的应用程序中,我正在尝试使用 AWS S3 上传图像。但是,当我从库中选择图像或捕获的图像时,在上传过程中我的应用程序崩溃了。

let path:NSString = (NSTemporaryDirectory() as NSString).appendingPathComponent("testImage.png") as NSString
let imageData:NSData = UIImagePNGRepresentation(image)! as NSData
imageData.write(toFile: path as String, atomically: true)
let url:NSURL = NSURL(fileURLWithPath: path as String)
let expression = AWSS3TransferUtilityUploadExpression()
expression.setValue("public-read", forRequestParameter: "x-amz-acl")
expression.setValue("public-read", forRequestHeader: "x-amz-acl" )
let transferUtility = AWSS3TransferUtility.default()

transferUtility.uploadFile(url as URL!, bucket: bucketURL, key: myImageUploadKey , contentType: "image/png", expression: expression, completionHandler: { (task, error) in

if error != nil{
print(error?.localizedDescription ?? "error")
}else{
print(task.response ?? "Response error")
}
})

expression.progressBlock = { (task: AWSS3TransferUtilityTask, progress: Progress) in
print("progress \(progress.fractionCompleted)")
}

应用程序在 let transferUtility = AWSS3TransferUtility.default() 处崩溃

所以请提出任何解决方案。将不胜感激。谢谢。



Best Answer-推荐答案


这个问题可能是由于 AWS S3 pod 更新而出现的。请检查最新的 pod。请查看 https://github.com/aws/aws-sdk-ios

关于ios - 应用程序在 swift 3 的 AWS S3 存储桶中上传图像时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42152318/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4