我正在尝试按照“上传对象”下列出的步骤操作:http: //docs.aws.amazon.com/mobile/sdkforios/developerguide/s3transfermanager.html
但是,我正在将内容转换为 Swift,因为这是我编写整个应用程序的内容。我提出了以下代码,但是当我运行它时,没有任何内容会上传到我指定的存储桶中。不幸的是,我什至没有收到错误,这使得故障排除变得困难 - 您可以在下面看到我正在尝试将任何错误打印到控制台,但 myBFTask.error 最终为空。同时 myBFTask.result 也为空。对于上下文,此代码都在 imagePickerController didFinishPickingMediaWithInfo 中。任何关于下一步看哪里的提示将不胜感激。
var pickedURL:NSURL = info[UIImagePickerControllerMediaURL] as NSURL
println("here's the url for the picked media: \(pickedURL)")
//make a timestamp variable to use in the key of the video I'm about to upload
let date:NSDate = NSDate()
var unixTimeStamp:NSTimeInterval = date.timeIntervalSince1970
var unixTimeStampString:String = String(format:"%f", unixTimeStamp)
println("this is my unix timestamp as a string: \(unixTimeStampString)")
var myTransferManagerRequest:AWSS3TransferManagerUploadRequest = AWSS3TransferManagerUploadRequest()
myTransferManagerRequest.bucket = "kikfli1.videolist"
myTransferManagerRequest.key = "\(self.fbid)_\(unixTimeStampString)"
myTransferManagerRequest.body = pickedURL
var myBFTask:BFTask = BFTask()
var myMainThreadBFExecutor:BFExecutor = BFExecutor.mainThreadExecutor()
var myTransferManager:AWSS3TransferManager = AWSS3TransferManager()
myTransferManager.upload(myTransferManagerRequest).continueWithExecutor(myMainThreadBFExecutor, withBlock: { (myBFTask) -> AnyObject! in
println("I'm inside the completion block")
if((myBFTask.result) != nil){
println("upload was successful?")
}else{
println("upload didn't seem to go through..")
var myError = myBFTask.error
println("error: \(myError)")
}
return nil
})
这是打印到我的控制台的内容:
用户选择了要提交的视频!
这是所选媒体的网址:file:xxxxxxxxxxxxxxx.MOV(显然是实际文件路径)
这是我作为字符串的 Unix 时间戳:1417506382.414219
我在完成块里面
上传好像没有通过。。
错误无