I've managed to setup AWS mobile hub and I can now login using my facebook credentials. Basically I just want to upload an image to the S3 bucket using AWSMobileHubHelper. I know in AWS Mobile hub things work differently to regular S3 upload. We're supposed to use AWSUserFileManager instead of the usual setup up AWScognito credentials + S3bucket etc.
I found this function in their documentation but there is no explanation whatsoever. I assume I can pass my image as NSData and the key would be my path "public/aaa". I ran the code everything seems fine. I doesn't even throw an error. But when I go to my S3 bucket,the image isn't there.
My question is: What am i suppose to pass as a key?? There is absolutely no documentation whatsoever on this.
If this is not how to do it? How does AWSUserFileManager work?
func uploadWithData(data: NSData, forKey key: String) {
let userFilemanager = AWSUserFileManager.defaultUserFileManager()
let localContent = userFilemanager.localContentWithData(data, key: key)
localContent.uploadWithPinOnCompletion(false, progressBlock: {(content: AWSLocalContent?, progress: NSProgress?) -> Void in
// handle progress here
}, completionHandler: {(content: AWSContent?, error: NSError?) -> Void in
if let error = error {
// handle error here
print("Error occured in uploading: \(error)")
return
}
// handle successful upload here
})
}
Thanks.