Images disappear after few hours - ruby-on-rails

I want to create little ticket system : http://ticketsystemkm.herokuapp.com/
I got posters for movies to display them on main site.
When i make new movie everything works good, but after few hours images disappear.
Maybe someone had similar problem and know how to solve it.

Guessing your images are user uploads via Paperclip, or something of the like, to your public folder, which is why they're disappearing. If your app doesn't receive any traffic for 15 minutes or so, the VM it lives on is destroyed, and the public folder goes along with it.
You need to store your assets on S3, or some of other CDN. The other option is to check the relevant assets into version control into app/assets/images.
A more detailed explanation (and solution) can be found here:
https://devcenter.heroku.com/articles/paperclip-s3

Issue can happen if you change default_url of uploader or uploaded files has been deleted
You should check something:
- image path in website
- default_url in uploader
- file in that path exist
I think we cannot store files in heroku, maybe it's cleared frequently
If upload file is cleared by heroku, you should store it external(S3, Azure Storage, Google Cloud Storage, ...)

Related

AWS S3 bucket images not appearing in Rails app

After finding that some large images were not appearing in my Rails app in Heroku, I opened an AWS account in the hope that they would be shown this way.
I uploaded my images to my S3 bucket and I registered the keys on Heroku, as per the tutorial on the Heroku site. Everything seems to be in place, so I referred to the images using the AWS link:
<img class="d-block w-100" src="https://s3-ap-southeast-
1.amazonaws.com/globalenglish1/EnglishUp-113.jpg">
But this this didn't work so I guess something is missing. The only thing that I can think it might be is that I didn't start my app in Heroku with a Procfile, and I can't find any way of creating a procfile now that I already have my app deployed to Heroku. But I don't really know if this is necessary, it's just my guess.
If anyone can give me any pointers, I would be most grateful.
As per the description provided and visiting the image source it seems that the public access has not been provided to view this image.
Please check for AWS console that the images stored on S3 bucket are publicly accessible or not.
If not then please provide public access and then check again.
For making the bucket public please find the below mentioned link.
Make a bucket public in Amazon S3
I think the problem is you have put with space ' ' on source URL like after https://s3-ap-southeast- it's with space see URL from your post it's not showing Image while I put into browser, but after removing this space like This URL it's showing image.
Check it out.

AWS S3 not showing images on heroku?

I built a rails app and set up s3 and paperclip together. So far, the images are being posted into my s3 account. But on the live app it's not actually showing the image and just showing the broken file icon.
Any ideas why this is happening? Is it a paperclip error? is it Heroku? Is it my controller?
Here's the live app: http://petaluma-marin.herokuapp.com/Nutrition-Recipes
Here's my repo: https://github.com/Gcamara14/Recipe_app
Thanks!!
Your url to the images is wrong. The URL for your second image currently is this
http://s3.amazonaws.com/recipe-app-gio/recipes/images/000/000/009/medium/Screen_Shot_2017-05-30_at_1.19.49_PM.png?1496243164
What it needs to be is this
http://s3-us-west-1.amazonaws.com/recipe-app-gio/recipes/images/000/000/009/medium/Screen_Shot_2017-05-30_at_1.19.49_PM.png?1496243164
Notice instead of http://s3.aws... at the beginning you need http://s3-us-west-1.aws...
Whenever I have issues with S3 I find it is easiest to go to the bucket and look at the path and then inspect the image or asset and see if they match.
To give you a hint about what the issue might be, in your browser if you copy/paste the url for a photo you should see this message:
The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.
Take a look at your paperclip_defaults. You are missing the s3_host_name that would contain something like s3-us-west-1 (as mentioned in one of the prior answers).
Also looks like there is an issue already created in the paperclip repo that should help you out (here).

Move Images From Parse To S3 AWS

I need help moving the images I have from Parse to S3 on AWS. I have viewed numerous supposed guides and GitHub projects, but everything stops short at giving you all the information. One even says, you need GCS bucket set up, but gives no details on how to set up one. Just someone please help me with this. I have the S3 File Adapter in my index.js all set up for the app, but none of the images are there, they are still hosted in parse.
If you are referring to old images that where hosted with parse.com that you want to move across to your own environment then it can be done with the utility tool.
Get all files across all classess in a Parse database. Print file URLs
to console OR transfer to S3, GCS, or filesystem. Rename files so that
Parse Server no longer detects that they are hosted by Parse. Update
MongoDB with new file names.
https://github.com/parse-server-modules/parse-files-utils
Moving forward if you have setup your S3 bucket correctly all new images from your app will be stored there.
https://github.com/ParsePlatform/parse-server/wiki/Configuring-File-Adapters

Uploaded files disappear during new push?

I have paperclip working just fine where I can upload files to my site, but whenever I make updates and push a new version of the site all of the files I uploaded via paperclip seem to disappear (All the information that was entered into the database remains though).
I assume the problem is that I haven't pulled the files from the live version of the site, but whenever I do a git pull it tells me everything is up to date. Is there anyway for me to download the files I've uploaded. (I would prefer to not use amazon S3 to store the files currently)
The files you have uploaded are stored at public folder. And public folder is not deployed with code, so your files are assuming to be disappeared.
If, you use amazon S3, then images will be stored at s3 and it will provide a dynamic url to access images. Then, you will be able to access images properly.
You can also save images at dropbox. In this application images are stored at dropbox and running on heroku. You may take the referance:
https://github.com/aman199002/Album-App # open source app to store albums(at dropbox).
http://album-app.herokuapp.com #Url of the application running on heroku.
When you deploy your application to Heroku, your pushed code is compiled into what is called a slug - this is essentially an archive of everything needed to run your application. When you restart or scale your application your original slug is then copied to be run. However, it's a readonly slug so when you upload files they exist on the dyno that received them so if you had multiple dynos your files wouldn't exist across them and they then do not persist when your application is restarted or you push new code nor is there any way to retrieve them.
Your only way to perist files on Heroku is to use an external cloud storage solution like Amazon S3, Rackspace files etc - fortunately it's very simple to have Paperclip use S3 for it's storage mechanism - there's a tutorial at https://devcenter.heroku.com/articles/paperclip-s3

Recommendations for file server to be used with Rails application

I'm working on a Rails app that accepts file uploads and where users can modify these files later. For example, they can change the text file contents or perform basic manipulations on images such as resizing, cropping, rotating etc.
At the moment the files are stored on the same server where Apache is running with Passenger to serve all application requests.
I need to move user files to dedicated server to distribute the load on my setup. At the moment our users upload around 10GB of files in a week, which is not huge amount but eventually it adds up.
And so i'm going through a different options on how to implement the communication between application server(s) and a file server. I'd like to start out with a simple and fool-proof solution. If it scales well later across multiple file servers, i'd be more than happy.
Here are some different options i've been investigating:
Amazon S3. I find it a bit difficult to implement for my application. It adds complexity of "uploading" the uploaded file again (possibly multiple times later), please mind that users can modify files and images with my app. Other than that, it would be nice "set it and forget it" solution.
Some sort of simple RPC server that lives on file server and transparently manages files when looking from the application server side. I haven't been able to find any standard and well tested tools here yet so this is a bit more theorethical in my mind. However, the Bert and Ernie built and used in GitHub seem interesting but maybe too complex just to start out.
MogileFS also seems interesting. Haven't seen it in use (but that's my problem :).
So i'm looking for different (and possibly standards-based) approaches how file servers for web applications are implemented and how they have been working in the wild.
Use S3. It is inexpensive, a-la-carte, and if people start downloading their files, your server won't have to get stressed because your download pages can point directly to the S3 URL of the uploaded file.
"Pedro" has a nice sample application that works with S3 at github.com.
Clone the application ( git clone git://github.com/pedro/paperclip-on-heroku.git )
Make sure that you have the right_aws gem installed.
Put your Amazon S3 credentials (API & secret) into config/s3.yml
Install the Firefox S3 plugin (http://www.s3fox.net/)
Go into Firefox S3 plugin and put in your api & secret.
Use the S3 plugin to create a bucket with a unique name, perhaps 'your-paperclip-demo'.
Edit app/models/user.rb, and put your bucket name on the second last line (:bucket => 'your-paperclip-demo').
Fire up your server locally and upload some files to your local app. You'll see from the S3 plugin that the file was uploaded to Amazon S3 in your new bucket.
I'm usually terribly incompetent or unlucky at getting these kinds of things working, but with Pedro's little S3 upload application I was successful. Good luck.
you could also try and compile a version of Dropbox (they provide the source) and ln -s that to your public/system directory so paperclip saves to it. this way you can access the files remotely from any desktop as well... I haven't done this yet so i can't attest to how easy/hard/valuable it is but it's on my teux deux list... :)
I think S3 is your best bet. With a plugin like Paperclip it's really very easy to add to a Rails application, and not having to worry about scaling it will save on headaches.

Resources