ABN
ABN

Reputation: 1152

What is the correct way to change FILE_UPLOAD_MAX_MEMORY_SIZE in django?

If I change FILE_UPLOAD_MAX_MEMORY_SIZE, do I have to change DATA_UPLOAD_MAX_MEMORY_SIZE as well?

Django default:

DATA_UPLOAD_MAX_MEMORY_SIZE = 2.5 Mb
FILE_UPLOAD_MAX_MEMORY_SIZE = 2.5 Mb

My api expects two files in a json request. Storing these files on disk is not an option. I have to work on these files in memory.

Should I just update FILE_UPLOAD_MAX_MEMORY_SIZE to 3Mb? Or should I change DATA_UPLOAD_MAX_MEMORY_SIZE to 8.5 Mb? Or should I change FILE_UPLOAD_MAX_MEMORY_SIZE to 3Mb and DATA_UPLOAD_MAX_MEMORY_SIZE to 8.5 Mb?

Upvotes: 1

Views: 1234

Answers (1)

Benbb96
Benbb96

Reputation: 2283

You should only change the FILE_UPLOAD_MAX_MEMORY_SIZE because DATA_UPLOAD_MAX_MEMORY_SIZE doesn't affect file uploads as you can read in the documentation :

The check is done when accessing request.body or request.POST and is calculated against the total request size excluding any file upload data.

Upvotes: 3

Related Questions