Storing images on a PaaS

15 views
Skip to first unread message

Ram Rachum

unread,
Jun 3, 2012, 12:35:11 PM6/3/12
to pyweb-il
Hey guys,

We were just about to launch our Heroku-hosted Django site, when we ran into a problem.

How do you store images on a PaaS like Heroku?!

The thing is that the filesystem on Heroku is ephemeral. Any file saved to it will be deleted once in a while. So you have to save files someplace else.

Django's ImageField uses the local filesystem by default, which would not work because of the above. I could connect it to other storage engines, such as those that use S3 or the database, but I'm not sure whether that will work well.

Did anyone solve this problem and can suggest their solution?


Thanks,
Ram.

Idan Gazit

unread,
Jun 3, 2012, 1:12:59 PM6/3/12
to pywe...@googlegroups.com
Short answer: use S3 for media uploads with django-storages.

Maybe answer: http://cloudinary.com/ (I know for a fact that they have a heroku addon in beta, but I don't know if that's publicly available yet.)

-I
> --
> You received this message because you are subscribed to the Google Groups "PyWeb-IL" group.
> To post to this group, send email to pywe...@googlegroups.com (mailto:pywe...@googlegroups.com).
> To unsubscribe from this group, send email to pyweb-il+u...@googlegroups.com (mailto:pyweb-il+u...@googlegroups.com).
> For more options, visit this group at http://groups.google.com/group/pyweb-il?hl=en.



Yuval Adam

unread,
Jun 3, 2012, 1:13:25 PM6/3/12
to pywe...@googlegroups.com
S3 is your best bet. django-storages works like a charm.

--
You received this message because you are subscribed to the Google Groups "PyWeb-IL" group.
To post to this group, send email to pywe...@googlegroups.com.
To unsubscribe from this group, send email to pyweb-il+u...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/pyweb-il?hl=en.



--
Yuval Adam
http://y3xz.com


Ram Rachum

unread,
Jun 3, 2012, 1:17:46 PM6/3/12
to pywe...@googlegroups.com
Please explain to me something about using S3 for this.

If I use S3, then I'm still using ImageField, except it stores to S3, right?

Now, I have several servers. A production server, a couple of staging  server , and a plethora of development servers. I assume I should be connecting all of them to the same S3.

Now, say I upload an image to S3 on one server. I'd like to have that image on another server. How would I add the image to the second server? I normally use the admin, but as far as I know the admin for ImageField only allows uploading, it doesn't allow specifying the path of an existing file.

Any clue?


Thanks,
Ram.

To post to this group, send email to pywe...@googlegroups.com.
To unsubscribe from this group, send email to pyweb-il+u...@googlegroups.com.

Yuval Adam

unread,
Jun 3, 2012, 1:49:41 PM6/3/12
to pywe...@googlegroups.com
Ideally the setup would be to use a separate bucket for each environment.
Personally, I prefer using local storage for local development.

Staging/testing is really up to you.
I would counter your question by asking how you keep your production and staging _databases_ synced.

Ram Rachum

unread,
Jun 6, 2012, 8:08:20 AM6/6/12
to pywe...@googlegroups.com
Thanks for all your help guys!

Eventually we went with storing the images in the local repo. Ugly but for now it's good enough, since we currently have only 5 images in this system. We'll probably go S3 in the future as we need to store more images.

On Sun, Jun 3, 2012 at 8:49 PM, Yuval Adam <yuv...@gmail.com> wrote:
Ideally the setup would be to use a separate bucket for each environment.
Personally, I prefer using local storage for local development.

Staging/testing is really up to you.
I would counter your question by asking how you keep your production and staging _databases_ synced.

Touché. Sometimes we use a fixture, but many times we have to resort to manual copying in the admin :(

Now we put the local-repo images in the fixture, so at least that part can be automatic.
Reply all
Reply to author
Forward
0 new messages