Я пытаюсь использовать новую версию AWS, которая была недавно выпущена, у меня есть более старая версия, работающая на Android, но я новичок в быстрой и более новой версии AWS S3 и был заблокирован для последние пару дней с этим вопросом. Я продолжаю получать сообщение об ошибке. Операция не может быть завершена. (Cocoa ошибка 260.)Swift/Objective S3 Загрузка файла
Вот мое приложение делегат
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let credentialsProvider = AWSCognitoCredentialsProvider.credentialsWithRegionType(
AWSRegionType.USEast1,
accountId: cognitoAccountId,
identityPoolId: cognitoIdentityPoolId,
unauthRoleArn: cognitoUnauthRoleArn,
authRoleArn: cognitoAuthRoleArn)
let defaultServiceConfiguration = AWSServiceConfiguration(
region: AWSRegionType.USEast1,
credentialsProvider: credentialsProvider)
AWSServiceManager.defaultServiceManager().setDefaultServiceConfiguration(defaultServiceConfiguration)
AWSServiceManager.defaultServiceManager().setDefaultServiceConfiguration(defaultServiceConfiguration)
return true
}
Кодекс, где я пытаюсь загрузить изображение в ведро
let fileUrl = NSURL(string:imagePath!)
println(imagePath)
UIImageJPEGRepresentation(self.image, 1).writeToURL(fileUrl, atomically: true)
var indent:NSString = "closr"
var uploadRequest:AWSS3TransferManagerUploadRequest = AWSS3TransferManagerUploadRequest()
uploadRequest.bucket = "closr-bucket"
uploadRequest.key = "filename.jpg"
uploadRequest.contentType = "image/jpeg"
uploadRequest.body = fileUrl
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) {
//failed
println("failed")
println(task.error.code)
println(task.error.localizedDescription)
} else {
//completed
println("completed")
}
return nil
}
Круто, в немного прогресса, кажется, отдай мне 'тело' не может быть нулевой код ошибки 5 – user1408682
путь к файлу «/ Var/мобильный/Контейнеры/Data/Application/12AF0267-7DB0- 4311-AC60-27CF3C72032B/Documents/photos/closr.jpg " – user1408682
изменен файлUrl в var fileUrl = NSBundle.mainBundle(). URLForResource (imagePath !, withExtension:" jpg ") – user1408682