Project

General

Profile

WFileUpload cached Request File

Added by Sven Matner over 10 years ago

I'm using a WFileUpload with the built in http server to upload a rather large file to an embedded device.

When i get the uploaded Signal the temp directory (which is tmpfs in ram) contains basically 2 copies of the file, the request and the file itself.

At this point i want to process the file, which means i'm running out of memory due to the request using up a large percentage of the existing ram.

Is there any way to get rid of the request file at this point? i could propably take the file and do a redirect to get a small requestfile, but that has the risk of not cleaning up the uploaded file correctly if the redirect is not followed.


Replies (4)

RE: WFileUpload cached Request File - Added by Wim Dumon over 10 years ago

Hello Sven,

Indeed, Wt starts parsing a request after it has received it completely. If Wt receives a large request (max-memory-request-size in wt_config.xml), it spools the request to a file. This often happens for file uploads. This is not purely the contents of the uploaded file, it's a multipart mime file that requires processing. The final uploaded file is the result of the processing, so that's the second file you see.

The request file is cleaned up after the file upload event was processed, in ~WtReply, because currently we have no earlier indication that Wt doesn't need the request anymore.

What can you do?

  • fire a singleshot WTimer in a short period, process file in timeout handler
  • require the user to push a button after the upload to start processing (if acceptable?)

Indeed redirect is also an option but maybe one of the two options above are easier?

Wim.

RE: WFileUpload cached Request File - Added by Sven Matner over 10 years ago

thanks for the suggestion, the timer does seem like a better controlable workaround, so i guess i'll go with that.

it would be nice to be able to process the file part of the request while reading it though, especially on embedded devices not caching the complete request at all could reduce memory/space requirements quite a bit.

RE: WFileUpload cached Request File - Added by Wim Dumon over 10 years ago

Hello Sven,

I agree. It's not a trivial change in Wt. Can you file a feature request on our bug tracker referring to this thread? ('New issue' at the top of this page)

BR,

Wim.

    (1-4/4)