saving photos with paperclip - ruby-on-rails

I have installed paperclip on my rails app (deployed on heroku).
On my localhost it worked fine, but on heroku it didnt work.
I looked at the log and found that this is the problem:
Errno::EACCES(Permission denied - /app/723a45cd/home/public/system):
It looks like it dont have permissions for "system" folder (its the pictures folder).
How I solve this?
Should I give the app permissions? If yes, how?
Thanks,
Oded

I don't think you can store uploaded files on Heroku, you'll have to use S3 as described in their documentation.

Heroku has a read-only file system (except the /tmp directory) which means you'll need to save your images elsewhere. Probably the best place is Amazon S3, which Paperclip happens to support natively.

Related

How to use File.new() in Rails app to create a file?

I would like to create some_javascript_file.js after a user submits a form and save this file in the public directory of my app.
When testing this localy I can simply use File.new("./public/some_javascript_file.js", "w") to accomplish this but this solution doesn't work when the app is deployed to Heroku.
Please would you have any suggestions? Thank you
This is because of how Heroku works. Basically, as stated in the docs, the filesystem is ephemeral and you can't rely on it. If you want persistence, you should upload this JS file to some external service, such as AWS S3. Or you might want to deploy your app to a different environment, such as self-managed VPS, where filesystem is real and your file won't disappear.

Best AWS Storage Option for Exporting Directories as .zip Files?

I'm brand new to AWS products, ruby on rails, web development, and coding of any type. For my first project after a quick (and dirty) bootcamp, I'm trying to build a ruby-on-rails website that stores images and allows the user to download them as a zip file. I used the RubyZip gem to accomplish this in my EC2 dev environment, but I have deployed to Elastic Beanstalk with S3 file storage, and the RubyZip gem seems unable to handle this structure without traditional directory targets for zipping.
My question is what's the best setup to achieve this functionality in EB? Disregarding the ruby constraint, zipping an S3 directory seems tricky. Should I move to EFS or another storage system? I plan to erase the folders regularly, and limit them to ~100 photos, so long term and large size storage are not a concern. Thanks very much!
Edit: I am attached to Ruby (only language I know), but not RubyZip, AWS, or much of anything else if they are not the best approach for this task.
I think you're on the right path as far as using S3 as a solution. The problem that your facing is that when you're interacting with S3 it's not like a folder on your local system, instead you're hitting the S3 API to interact with the files. (upload, edit, delete ect). This will be a problem you'll encounter with every AWS based storage solution.
I think the solution, in your case, is to fetch all of the photos and download them to a temporary folder on your local system. Then, you could zip them using Ruby, locally. After it's zipped, upload it back to S3.
Edit: By locally I mean onto the server where the Ruby application is running (not client-side)

Why does changing my VM's tmp folder permissions cause my rails server to break?

I'm working on an upload method to s3 and was starting work on it locally. Making sure I understood how to root uploaded files to the proper location. I had it working in the public folder, but as my work is sensitive this clearly was a temporary notion. I switched the filepath over to my 'tmp' folder and my uploader worked! However, when I went to restart my rails server (after adjusting routes), it was not able to turn off my server properly.
If anyone has run into this before any help would be greatly appreciated :)

What should i use for rails file attachment and jruby?

Normally I'd use carrierwave, but they do not officially support jruby, and I've been running in to bugs, possibly related. (https://github.com/jnicklas/carrierwave/issues/620, Image corruption on upload to s3, production only. (carrierwave, engineyard))
Have others had success here?
I'm considering trying out paperclip, but it looks like that may not be perfect either-- https://github.com/thoughtbot/paperclip/issues/100
Try dragonfly it's a really great library to manage you file attachment.
check out this guide, it's cake
http://webtempest.com/how-to-allow-image-uploads-in-rails-on-heroku/
It uses paperclip and amazon web s3 gems

Automate deployment of files to Amazon S3?

I have a Rails project that I will be deploying to the spectacularly awesome Heroku.
I would really like to be able to automate pushing my resources to Amazon S3 automatically, resources in this case being my images, stylesheets and javascript.
Obviously I can write some sort of capistrano task to do this myself, but does anyone know of something that does this already?
Note: I don't need to be able to upload user-files to S3 as I do that already via paperclip. I am talking about the actual project files required to run the site.
I found a good article which actually explain about the method to minify, compress and upload the static conetents (js/css) to Amazon S3 using Capistrano script.
Check the article at http://www.makeurownrules.com/ruby-on-rails/minify-compress-synch-amazons3-capistrano
Cheers,
Kapil
I bumped into your question looking for the same answer. I have good experience with Jammit as an asset packager and I just bumped into a gem which can deploy to S3 and seems to perfectly fit your needs.
https://github.com/railsjedi/jammit-s3
Best,
Jeroen
I tried Jammit S3, but it didn't have the control I was looking for, so I wrote my own CLI script and just got around to publishing it:
https://github.com/bradt/git-deploy-s3
There is also capistrano-s3 gem which is similar to jammit-s3 but a bit simpler and framework agnostic.
It simply publish all files in your public folder to amazon s3 using capistrano so you may add custom hooks. Have a look at the doc here :
https://github.com/hooktstudios/capistrano-s3
I does not deal with CloudFront invalidations, but I plan on adding this feature.

Resources