Upload files to separate server from Django

266 views
Skip to first unread message

bradford....@gmail.com

unread,
Feb 25, 2008, 4:34:17 PM2/25/08
to Django users
I've been trying to find an answer to this question for a while and it
seems like there are some ideas floating around but no definite
answer.

I have a photo site hosted with WebFaction that I have all my django
code running on. However, I have another host that I'd like to serve
all the media for the site from. This isn't a problem for things like
CSS and even core site images but obviously as it is right now, I
can't upload files from the Django admin to the same server that my
static media is serving from.

Is there a way to set up django so the files will upload to a
different server entirely from where django is running?

I've had ideas of using rsync or scp but I'd like this to be as
streamlined as possible. With rsync or scp, I'd need to have it check
when a new file is added to a folder on my WebFaction account and then
automatically transfer that file to my other host and then delete that
file from WebFaction...which I think would be pretty complex to set
up.

Another option is using Amazon S3 which I've seen working for other
people but I'd really like to just use what I already have and not
depend on S3.

Any ideas?

Thanks in advance!

alex....@gmail.com

unread,
Feb 25, 2008, 4:55:02 PM2/25/08
to Django users
There is currently a ticket for this: http://code.djangoproject.com/ticket/5361
I'm not sure what the status of it is, but for usage(with manual
uploads, or if you try the patch), check out: http://www.b-list.org/weblog/2008/feb/07/media/

On Feb 25, 3:34 pm, "bradford.mcgoni...@gmail.com"

Malcolm Tredinnick

unread,
Feb 25, 2008, 6:15:22 PM2/25/08
to django...@googlegroups.com

On Mon, 2008-02-25 at 13:34 -0800, bradford....@gmail.com wrote:

[...]


> I've had ideas of using rsync or scp but I'd like this to be as
> streamlined as possible. With rsync or scp, I'd need to have it check
> when a new file is added to a folder on my WebFaction account and then
> automatically transfer that file to my other host and then delete that
> file from WebFaction...which I think would be pretty complex to set
> up.

You're over-estimating the complexity. Run rsync from a cronjob and then
periodically clean up the directory on the source machine (maybe every
few days or weeks or whatever). Rsync isn't going to copy stuff that
already exists, so you can leave the source around for a while.

Malcolm

--
Why be difficult when, with a little bit of effort, you could be
impossible.
http://www.pointy-stick.com/blog/

Leonel Nunez

unread,
Feb 25, 2008, 6:37:20 PM2/25/08
to django...@googlegroups.com


And what if you store the images on the database as part of your record ?
This will give you integrity


Leonel

the.re...@gmail.com

unread,
Feb 25, 2008, 6:57:14 PM2/25/08
to Django users
I'm not certain about the practicality of this (it may have security
or performance implications that i'm unaware of), but i've often
thought about mounting the media server as a network drive on your
dynamic server and giving Django full read-write privileges. This
would mean that you don't actually have to write any special code to
use your separate server since Django wouldn't need to know that the
file is going somewhere completely different.

On Feb 25, 9:34 pm, "bradford.mcgoni...@gmail.com"

bradford....@gmail.com

unread,
Feb 25, 2008, 8:56:24 PM2/25/08
to Django users
Cool, thanks or the help guys! I'm going to try to figure out this
JellyRoll thing and bypass all of this by using Flickr...for now at
least...

On Feb 25, 6:57 pm, "a...@andrewingram.net" <the.real.a...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages