How can I serve or upload (uploading files from the website) media files to a remote server. One way would be ssh using fabric. But Using it I can transfer the files from one host to the remote host in case of static files (as in documentation). But is it possible that, whenever a user uploads a file in the website, it goes directly to the remote server
e.g. instead of file going to
MEDIA_ROOT = '/usr/files/'
on the same server, it will go to folder located in remote server.
Have you tried this solution:
https://github.com/aaugustin/django-resto
it has three modes of working according to the docs:
HybridStorage
With this backend, django-resto will run all file storage operations on MEDIA_ROOT first, then replicate them to the media servers.
AsyncStorage
With this backend, django-resto will run all file storage operations on MEDIA_ROOT and lanch their replication to the media servers in the background. See Asynchronous operation.
DistributedStorage
With this backend, django-resto will only store the files on the media servers. See Low concurrency situations.
And the servers that listen for incoming content can be a lighthttp implementation on nginx, as the docs recommend:
Here is an example of lighttpd config:
server.modules += ( "mod_webdav", ) $HTTP["remoteip"] ~= "^192.168.0.[0-9]+$" { "webdav.activate = "enable" }
Here is an example of nginx config, assuming the server was compiled --with-http_dav_module:
server {
listen 192.168.0.10;
location / {
root /var/www/media;
dav_methods PUT DELETE;
create_full_put_path on;
dav_access user:rw group:r all:r;
allow 192.168.0.1/24;
deny all;
}
}
Hope this solves your issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With