简体   繁体   中英

Uploading image from PhoneGap to Carrierwave / Rails 3?

I'm trying to figure out the best way to upload a camera image from a PhoneGap app to a Rails 3 app that has Carrierwave on it. My thoughts so far:

Option 1) Use phonegap filetransfer functionality to upload to a temp folder on S3 then assign the URL to the remote_avatar_url for my carrierwave field. Then carrierwave does all the work for me in terms of grabbing the image, resizing, cropping, etc. Carrierwave will then send the files back over to S3 where they will be stored in the right places.

Option 2) Use phonegap filetransfer functionality to upload directly to my rails server then let carrierwave do the work from here. This seems more efficient, but I don't know how to assign an image that was posted to a rails api controller to Carrierwave so that it can do its thing. Any ideas assuming this is the best way to handle?

Thanks!

You can send the image as Base64/encode and than parse it on the CarrierWave side. Take a look at http://ograycoding.wordpress.com/2012/07/03/api-upload-with-carrierwave/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM