Mahdi
Mahdi

Reputation: 170

where django create InMemoryUploadedFile object of uploaded file?

when a HTTP Post request came with a file , django will create a InMemoryUploadedFile instance for each uploaded file.
I'd like to extend InMemoryUploadedFile and add a few field and finally customize the upload file behavior of django.
I took a look on django.middlewares but I didn't fined any middleware related to this behavior.
how django does this ?
how can I customize this behavior ?
thanks a lot

Upvotes: 0

Views: 1929

Answers (1)

Mahdi
Mahdi

Reputation: 170

I just found the answer to my question. there is a setting in django for this purpose called FILE_UPLOAD_HANDLERS
the only thing we need to do is creating a new File Handler class which can be an extended version of either MemoryFileUploadHandler or TemporaryFileUploadHandler .
after creating this new class we should add our class name to the FIRST item in the tuple for FILE_UPLOAD_HANDLERS.
for more documentation please take a look at this page

Upvotes: 2

Related Questions