I am developing an iPhone app in Appcelerator Titanium. My app is communicating with an API that I build using Rails 3.
I want to be able to upload an image from the iPhone app to the API (and Amazon S3). I am using the gem called Paperclip. Along with the upload request I need to send the name of the file. But if I do it like below, the image_file_name is not recognized. What is wrong with the call?
In the App: http://pastie.org/1805065
In the API model: http://pastie.org/1805071
In the API controller: http://pastie.org/1805073
Output on the API server: http://pastie.org/1805078
Looks like in the API Controller the line:
#avatar = Avatar.new(params[:avatar])
Should read:
#avatar = Avatar.new(params[:image])
Explanation:
This conclusions was made by looking at the server log output from the API Server, and checking the Parameters hash for the name of the submitted image. Instead of it being named "avatar" as your controller was expecting, it appears to actually be named "image".
Related
How to launch a specific page of hybrid worklight application on clicking a link in email?
I did not go through all the steps involved, but yes, you can do this.
Step 1
Create a Worklight application using, for example, jQuery Mobile to handle the multiple pages
Step 2
If the app is intended for Android, you will need to modify the AndroidManifest.xml file with an intent filter in order to associate the app with an action and a custom URL scheme
You can read more about this by googling for "opening android application using a custom URL scheme", for example
If the app is intended for iOS, you will need to modify the <app-name->info.plist file with a custom URL scheme
You can probably follow this guide: http://iosdevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html
Step 3
Once you get the app to open from an external link, you need to handle the parameters. You'll want this since you want to open a specific page. This is also mentioned for iOS in the above link, and you'll need to further google this for Android
Step 4
Once you've obtained the parameter, you can use the Send Action to JavaScript from Native API for iOS and Andriod in Worklight in order to pass a command to JavaScript, telling the web code to do some changePage function that will load the specific page
I'm working on a Rails app which consumes the Instagram API to get a set of pictures. I want to store those pictures locally using CarrierWave to remote upload them. I know if you're using a controller, you can supply a url as the remote_image_url variable and CarrierWave natively knows what to do.
My question is: how can I get CarrierWave to do this from the Model? As I don't have a controller since I'm getting everything from the API.
Many thanks!
You can set remote_image_url anywhere, not just in a controller.
I am creating a mobile app through Phonegap as the client and using Rails as the back-end. I am deploying my app to Heroku and am planning to use S3 to store the image files, because that is what is recommended from my various readings online.
I was wondering how could the Rails controller be used to send images back from Ajax requests from Phonegap.
I am not sure how to write the back-end API code to send images to requests.
I also read that using the send_file method without x-send_file enabled will slow down the server because sending the image would block other request until it is done.
Please let me know if you have any insights.
You could use redirects to the S3 assets here, then your browser is just getting the image directly, and not holding up one of your server processes while the browser slowly downloads the images.
If you need to keep your images private you can use the signed URL feature of S3 to only give signed and time limited URL's to the appropriate users. (See my commit to Paperclip: https://github.com/thoughtbot/paperclip/pull/292)
I managed to create a small app that uses backbone.js for CRUD process.
Now i am trying to include file upload as well in "Create". i m using "paperclip" to upload image. As i am learning about backbone.js please tell me some approach to making it?
You cannot do this with backbone models. You will have to create a form (including the file field) on the client side and post form to the server.
You can use something like that on the client:
http://www.williambharding.com/blog/rails/rails-ajax-image-uploading-made-simple-with-jquery/
You may want to check out the jquery.iframe.transport plugin. Since you're using rails 3, you can use remotipart instead (it bundles the iframe.transport plugin), which hooks into rails's ujs driver to automatically add support for file upload in ajax requests.
I'm trying to get S3 SWF Uploader plugin working on my Heroku hosted RoR app.
At this point i have it installed, and i can upload files to my Amazon bucket... that's great!
But how can i get my hands on the callback functions? I simply can't find them!
Thanks
He has a list of all the Javascript callbacks in the README on GitHub: https://github.com/nathancolgate/s3-swf-upload-plugin
He also has a sample app which shows the code and how he's using the callbacks: http://s3swfuploader.heroku.com/
The one you'd be interested in is: :onUploadingFinish ()