Use "server.stream-request-body = 2" in lighttpd configuration to enable stream transfer over the buffered upload option.
This can be used to write a new uploader which directly writes into the target directory.
I'm also against using C programs in PirateBox. Yes, it should be possible to use other languages (everything that you can use for CGI + that can read environment variables and stdin should be good).
Lighttpd gives two important environment variables to the CGI script: REQUEST_METHOD (should be "POST" ) and CONTENT_TYPE (should start with "multipart/form-data" and also contain the boundary). Then there's a third one: CONTENT_LENGTH - This is the length of the bytestream waiting on stdin. There might be more environment variables but these are what my c tool uses to determine it's really a file upload. Then it's code that should be simple to port in any other language:
Language: C
while(len > 0) // len == CONTENT_LENGTH
{
size_t got = fread(buffer, 1, len < BUFSIZE ? len : BUFSIZE), stdin);
if(len < 1)
{
// Error handling here
}
else
{
len -= got;
// Do something with the buffer, i.e. find boundary, read header, pipe body to a file, ...
}
}
The crucial PHP option is upload_tmp_dir , which can only be set in the system configuration. Not in a user configuration. So a separate php-ini is needed or we change the system's one
Simple upload is working quite well with the lighttpd option. "server.stream-request-body = 2" It seems we can use /tmp (memory) for the lighttpd tmp files, which can save IO . Lighttpd only stores small chunks. yay.
First set of changes is pushed into feature-branch "feat-phpupload".
Done:
Generation of piratebox_config.php with the config settings of piratebox.conf
Customization of php.ini during start of piratebox. This is needed to save the receiving file already on the USB stick. We need to do this to save costy IO, the later move into the upload folder is only a filesystem rename and no physically move anymore.
We add options to allow overwriting of uploaded files.
First raw set of default template engine, which will be enhanced with later features (directory listing).
Adjusted OpenWrt reconfiguration (CHMOD setting).
Still to do:
Create a spinning logo while upload like on droopy
Use "server.stream-request-body = 2" in lighttpd configuration to enable stream transfer over the buffered upload option. This can be used to write a new uploader which directly writes into the target directory.
Language: C
by V10lator via https://forum.piratebox.cc/read.php?3,6801,20545#msg-20545