这是我将代码上传到存储桶AWS S3的代码。 (appdelegate中的凭证部分是商品)。
url = NSURL(fileURLWithPath: NSTemporaryDirectory().stringByAppendingPathComponent("tmp.jpg"))
UIImageJPEGRepresentation(self.photo.image, 1).writeToURL(self.url, atomically: true)
uploadRequest = AWSS3TransferManagerUploadRequest()
uploadRequest.bucket = "BUCKETNAME"
uploadRequest.key = "filename.jpg"
uploadRequest.body = url
uploadRequest.uploadProgress = { (bytesSent:Int64, totalBytesSent:Int64, totalBytesExpectedToSend:Int64) -> Void in
dispatch_sync(dispatch_get_main_queue(), {() -> Void in
println(totalBytesSent)
})
}
AWSS3TransferManager.defaultS3TransferManager().upload(uploadRequest).continueWithBlock { (task) -> AnyObject! in
if (task.error != nil) {
if( task.error.code != AWSS3TransferManagerErrorType.Paused.hashValue
&&
task.error.code != AWSS3TransferManagerErrorType.Cancelled.hashValue
)
{
//failed
println("failed")
}
} else {
//completed
println("completed")
}
return nil
}
问题是,我收到了这条消息的崩溃:
-[AWSS3TransferManagerUploadRequest encodeWithCoder:]: unrecognized selector sent to instance 0x7fba9b63ddb0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AWSS3TransferManagerUploadRequest encodeWithCoder:]: unrecognized selector sent to instance 0x7fba9b63ddb0'
有什么想法吗?很难找到aws和swift的帮助。
谢谢!