2017-02-10 95 views
2

在我的應用程序中,我嘗試使用AWS S3上傳圖片。但是,當我從庫或捕獲的圖像中選擇圖像時,在上傳過程中,我的應用程序正在崩潰。應用程序在AWS S3存儲桶上傳圖片時崩潰了swift 3

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)") 
} 

應用在讓transferUtility = AWSS3TransferUtility.default()

所以請提出任何解決辦法越來越墜毀。將不勝感激。謝謝。

+0

崩潰日誌?錯誤?什麼? –

回答

相關問題