簡體   English   中英

應用程序在AWS S3存儲桶中的上載映像時崩潰,導致Swift 3

[英]Application getting crashed at upload image in AWS S3 bucket for swift 3

在我的應用程序中,我嘗試使用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()導致應用程序崩潰

因此,請提出任何解決方案。 我們將不勝感激。

可能是由於AWS S3 pod更新導致了此問題。 請檢查最新的Pod。 請查看此https://github.com/aws/aws-sdk-ios

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM