I am allowing users to upload images with chunks. What is the appropriate way to reference the file from the database without resaving the file with FileField? I’m saving as follows:
def handle_uploaded_file(f):
with open('some/file/name.txt', 'wb+') as destination:
for chunk in f.chunks():
destination.write(chunk)
You should write the chunks to a Django File object and save it to a model’s FileField.
Then that saved file will live in your
MEDIA_ROOTdirectory, and you will be able to domymodel.myfile.urlto share that file’s public url if needed.