Ryo Hanaba
Ryo Hanaba

Reputation: 21

Django: How to upload directly files submitted by a user to another server?

Could somebody tell me how to do this?

Upvotes: 2

Views: 1277

Answers (2)

Jonathan Vanasco
Jonathan Vanasco

Reputation: 15680

You can't actually do both of these at once:

  • I'd like to upload directly these files to the file server.
  • I'd like to make the file server simple as possible. The file server just serve files.

Under your requirements, the file server needs to both Serves Files and Accepts Uploads of files.

There are a few ways to get the files onto the FileServer

  • the easiest way, is just to upload to the AppServer and then have that upload to another server. this is what most AmazonS3 implementations are like.
  • if the two machines are on the same LAN , you can mount a volume of the FileServer onto the AppServer using NFS or something similar. Users upload to the AppServer, but the data is saved to a partition that is really on the FileServer.
  • You could have a file upload script work on the FileServer. However, you'd need to do a few complex things:
    • have a mechanism to authenticate the ability to upload the file. you couldn't just use an authtkt, you'd need to have something that allows one-and-only-one file upload along with some sort of identifier and privilege token. i'd probably opt for an encrypted payload that is timestamped and has the upload permission credentials + an id for the file.
    • have a callback on successful upload from the FileServer to the AppServer, letting it know that the id in the payload has been successfully received.

Upvotes: 1

Carlos Castellanos
Carlos Castellanos

Reputation: 2378

I think what you need is static url setting for django 1.4 in order to make available file server files from the app server. For uploading files to file server you can write a python or php script hosted on this server (assuming apache2 server or similar) to get the job done.

I you have this ideas, i think you dont need to keep track of what files are uploaded (take into account that by using this solution you just can't)

Upvotes: 0

Related Questions