I'm trying to follow the steps listed here under "Upload an Object": http://docs.aws.amazon.com/mobile/sdkforios/developerguide/s3transfermanager.html
However, I'm converting things over to Swift because that's what my whole application is written in. I've come up with the following code, but when I run it nothing gets uploaded to the bucket I specified. Unfortunately I don't even get an error, which makes it hard to troubleshoot - you can see below that I'm trying to print any error to the console, but myBFTask.error ends up being null. At the same time myBFTask.result is also null. For context, this code is all inside the imagePickerController didFinishPickingMediaWithInfo. Any tips on where to look next would be greatly appreciated.
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
})
Here is what gets printed to my console:
the user picked a video for submission!
here's the url for the picked media: file:xxxxxxxxxxxxxxx.MOV (obviously an actual file path)
this is my unix timestamp as a string: 1417506382.414219
I'm inside the completion block
upload didn't seem to go through..
error nil
You are not passing
AWSServiceConfiguration
toAWSS3TransferManager
, and it's causing the issue. You need to change the following line:to something like
Also, you need to set the default service configuration to the default service manager in advance.