John Cowan
John Cowan

Reputation: 1674

How do I upload images to my heroku app

I am following a tutorial on deploying a Rails app to Heroku. It is using a free heroku account with a name like tranquil-mountain-51138.herokuapp.com. The tutorial does not cover adding images. I have a simple test site up and working. Now, I'd like to add a few images to the site, but have no idea how to do this.

On non-heroku, non-rails apps I use FileZilla to ftp files to the server, so I'm very familiar with that. Is there something similar for heroku?

Would someone point me to a tutorial on how to do this?

Much appreciated.

EDITED I would like to upload a photo to appear on my public/index.html page. That's all. I created and deployed a simple job-tracking app, which does not need pictures. Now I am just looking for a "how to" on adding images to an app on heroku - for learning purposes.

Thanks

Upvotes: 7

Views: 14403

Answers (3)

Maxence
Maxence

Reputation: 2339

If you only need to display an image that you provide, just add the appropriate helper in your view file :

image_tag('myimage')

myimage being located in app/assets/images folder. When an image is located in that specific folder, it will belong to the asset pipeline and then will be discovered automatically by the Rails app.

If you want to allow your users to upload images, then you have to use a gem such as Paperclip or Carrierwave which will allow to upload the image remotely (to Amazon S3 or other data services)

Upvotes: 0

bkunzi01
bkunzi01

Reputation: 4561

Since your comment says you aren't allowing users to upload images you don't need to do anything at all for displaying existing images (or files in general) to Heroku. As long as you have the images in your assets/images folder and it is referenced and setup in your app on your local machine, it will be permanently stored by Heroku and displayed on your site when you "git push heroku master". Just keep in mind, there is additional work to be done if you decide to have users upload pictures which involves adding Paperclip & S3 storage on Amazon since Heroku uses an ephermeal storage system.

Summary: Just deploy your app and your images will be there.

Upvotes: 2

Allam Matsubara
Allam Matsubara

Reputation: 529

If I'm not mistaken, Heroku doesn't allow writes on its filesystem, so, you would not be able to upload a file t your application at Heroku. That's why they suggest you to use and integrate Amazon S3 as a storage option.

Upvotes: 4

Related Questions