Project

General

Profile

Spooling uploaded file twice

Added by Erhan Aydın over 8 years ago

Hello all,

As we saw, uploaded files are spooled to /tmp twice. After upload is completed, a second file is generated. Naming convention is kept and first file which is copied, is deleted afterwards. Only then uploadFinished signal is emitted and WFileUpload::spoolFileName method returns second file's name (which is copied from the original uploaded file), since the original is no longer exists.

This causes uploading event (copying a relatively big file) to take longer time even though it is finished and moreover if there is not enough space for the file to be uploaded and copied (double the size of the file), second file is going to be corrupted and upload will not be complete.

Thanks in advance.


Replies (2)

RE: Spooling uploaded file twice - Added by Wim Dumon over 8 years ago

Hello Erhan,

What you see are two independent mechanisms. Wt starts processing a request as soon as it is completely received. Large requests are not fully stored in memory, but are spooled to a file. This is the first file you see. This file contains HTTP headers, MIME headers, ... There may be multiple files in the request. This is thus not the correct contents of the uploaded file. When the request is complete, Wt processes the HTTP request and extracts the files. At this moment, the second temp file is generated.

Extracting the file contents right in the first step is currently not possible in Wt, and not a trivial change.

Best regards,

Wim.

RE: Spooling uploaded file twice - Added by Erhan Aydın over 8 years ago

Thanks Wim. I got it now.

    (1-2/2)