[Django]-Django Storages [file upload to AWS S3]

2👍

Django-storage uses boto3 for uploads, as can be seen in its source code here:

obj.upload_fileobj(content, ExtraArgs=params)

which is the upload_fileobj method in boto3:

Upload a file-like object to this bucket. The file-like object must be in binary mode. This is a managed transfer which will perform a multipart upload in multiple threads if necessary.

Looking at the save method in Django-storage it future explains:

Save new content to the file specified by name. The content should be a proper File object or any Python file-like object, ready to be read from the beginning.

So to answer your question, the file must go through your server first so that you can create file-like object for it. It does not have to be necessarily stored on a hard drive, but the file data can be in memory. Also I think it also does not have to be fully stored, it should be possible to steam it as its being uploaded to your app, but I’m not certain if this works in django.

To sum up, all uploaded files must go through your server taking it processing power and bandwidth.

👤Marcin

Leave a comment