Reputation: 45
I am building an iphone app that lets users take a picture and leave a comment. The posts are saved to a rails-backed server. In my rails app I use the gems: minimagick, carrierwave and fog to upload and store the image to S3.
However - I am not sure how this connection persists when uploading a photo from the iPhone- what I mean is, I am able to save a post on the iphone, using AFNetworking, but the photo is not uploaded to my S3 bucket. So how do I upload photos to S3 - should I not even be saving to the server, and just have everything saved to S3?
I have seen some possible methods involving the AFNetworking S3 Client, and looked at the iosforaws sdk, as well as ASIHTTPRequest - but I am sort of at a loss and not sure how to proceed to save the images to S3. Which option should I pursue?
I haven't seen a clear postPath directly to the bucket on AWS- so I haven't been able to implement saving to S3 the same way I save to the rails server. How does this work?
I haven't been able to find a thorough tutorial on this so any info would help. What I am guessing I need to do is in my AddPhotoViewController, in the onSave method where the photo is uploaded to the server, I will add an s3client- sort of like having a parallel api- on goes to the server on heroku, one goes to s3. Is that right?
Upvotes: 1
Views: 1277
Reputation: 2809
I would advise that you relay the image to the server which uploads it to S3 for you. You will need to have this happen synchronously so that the app knows it is ready to share. It is important because S3 location or credentials may change and you do not want to be forced to update the app if this happens.
Yes, the server now becomes the S3 client, and returns the result of S3 update into your API return to the iPhone client.
Upvotes: 1