My web app allows users to record their geolocation data. I need to somehow get that geolocation data into a file so I can put it in s3 storage. I have no idea how to go about this, but the controller already has file uploads to s3 set up using paperclip.
Is there some way to generate a file with javascript and then attach that file when the user clicks save? The other option I was thinking is that I could add a bunch of strings to the body using jQuery .data() method, but then I don’t know how to attach a string as a file in my rails 3 form.
Any help is appreciated.
maybe you should try out Amazon’s simple db instead of s3 for this? It would be more appropriate than creating files to store data in s3.
Amazon recently released a ruby sdk for their web services, SDB included:
https://github.com/amazonwebservices/aws-sdk-for-ruby
Edit: Or better yet, forget using SDB directly. I had forgotten that that SDK includes an implementation of ActiveModel called AWS::Record. Should make this trivial.
I’m assuming you’re on Heroku or something and don’t have a method of data persistence?
edit: looking quickly at paperclip’s assign method, there’s a chance this would work.
Paperclip appears to handle creating a tempfile from the stream.