【发布时间】:2017-02-10 14:18:35
【问题描述】:
在我的应用程序中,我正在尝试使用 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() 处崩溃
所以请提出任何解决方案。将不胜感激。谢谢。
【问题讨论】:
-
崩溃日志?错误 ?有什么事吗?
标签: ios amazon-s3 swift3 aws-sdk