Migrating from Carrierwave local to S3? - ruby-on-rails

Our server ran into a file limit issue with carrierwave. Over 36000 files. We are now going to move to S3.
Is there a way to migrate the files over to S3? When we launched the code on production none of the images showed up and there was a duh moment. It's trying to grab the files from s3 when they are locally stored on the server still.
How do we migrate the files over?

You can upload the files to s3 via the s3 console in the s3 file manager. Or by using a plugin such as S3Fox for FireFox. You'll just need to make sure the pathing and the s3 bucket are such that Carrierwave will know how to point to the image via the right set of subfolders, etc.

Related

Images in public folder not found after each push on heroku

I am having issues with my Rails App on Heroku.
After every push to heroku any images I uploaded with paperclip Gem return a 404 error message.
How I resolve this?
You cannot use the local file system on Heroku to store uploaded files, because you get a new instance each time you deploy. I advise to read about Ephemeral filesystem on Heroku.
To fix your problem you show store uploaded files on an external service like Amazon S3. You might want to follow Heroku's documentation about uploading to S3

Using AssetSync to deploy to an S3 bucket subdirectory

I'm using AssetSync to sync to an S3 bucket. It seems to work fine. However, I'd like to be able to add versioning to the S3 bucket. So instead of just the bucket name, I want to put the deployed assets into a subdirectory like
my-bucket/v1/
I tried adding the 'v1' folder to the FOG_DIRECTORY env var, but that doesn't seem to be the thing to do. Is there an easy way to specify a subdir of a bucket?
Found the answer myself. Thanks for nothin'.
AssetSync.config.assets.prefix

download folder as zip from s3 carrierwave rails heroku

For a rails app using carrierwave and s3
How do you serve a directory as a zip file?
i have
/folder/
file1.png
file2.png
file3.png
When the user goes to /folder.zip they should be downloading a '.zip' file containing the above directory.
Is this something I need to set up with s3? Is it something carrierwave does? Do I need another gem for this?
A bit late, but I've ran into the same problem.
You might check Downloading and zipping files that were uploaded to S3 with CarrierWave

Precompiling uploaded assets

I have a rails 3.1 application where users upload pictures. I am storing them in /assets/images since that is the path image_tag looks for instead of public/images.
Everything works fine in development but I deployed to Heroku and it gives me this error:
ActionView::Template::Error (image_name.jpeg isn't precompiled)
What is the right way to handle such a situation? Is there a way to compile images after uploading or should I store them somewhere else?
You must not use the filesystem on Heroku to store uploads.
You should not use image_path with uploaded images, since that assumes it is looking at the filesystem. If you use image_tag, you must pass a complete URL, not just an image name.
Are you using carrierwave for your images uploads? You can store them on amazon S3 reasonably easy with carrier wave. Carrierwave instructions Other solutions have S3 storage easily accessible as well.
Heroku will NOT let you store files in the filesystem. Run
RAILS_ENV=production bundle exec rake assets:precompile
to compile you assets locally, add to git, and push to heroku but you cannot add images later via your application on heroku. If you upload them to the /temp folder they will stay there for a short while or until you re-deploy/update your code I believe.

Paperclip and Heroku without s3?

I'm trying to upload a file using paperclip in a production environment in Heroku and the log files show:
Errno::EACCES (Permission denied - /app/public/system/photos/1/small/081811-2012-honda-cbr1000rr-leaked-003.jpg):
Will I have to use s3 or similar to handle file uploads, or can I configure path permissions to store the files on Heroku?
Yes Heroku does not allows you to add files dynamically to its server.
Though if you need upload feature on a app on heroku you need to configure s3 or other similar services
Refer this for details
http://devcenter.heroku.com/articles/read-only-filesystem
Yes, you must use S3 or another persistent store like Rackspace cloudfiles, Dropbox etc.
Whilst you can write to the tmp on all the stacks, the Cedar stack does let you write to the file system but it's not shared across dynos or dyno stop/restarts.
See http://devcenter.heroku.com/articles/dyno-isolation#ephemeral_filesystem
Yeah, it is true that Heroku does not allow you to upload files directly onto their servers. However, you can shove your files into your database. I used a gem created by Pat Shaughnessy:
http://patshaughnessy.net/2009/2/19/database-storage-for-paperclip
It worked well.

Resources