changed values for send_file_mode config parameter:

0 - winix will read the content of the file and send it back to the webserver
  1 - winix will use send_file_header header with a full path to the file
  2 - winix will use send_file_header header with a relative path to the file
This commit is contained in:
2021-09-17 03:35:56 +02:00
parent 55ac9a61ed
commit 26ed7b80be
5 changed files with 90 additions and 29 deletions

View File

@@ -73,18 +73,32 @@ void Download::MakeGet()
cur->request->send_as_attachment = cur->request->IsParam(L"attachment");
bool is_thumb = (cur->request->item.item_content.file_has_thumb && cur->request->IsParam(L"thumb"));
if( config->send_file_mode == 0 )
if( config->send_file_mode == 0 || config->send_file_mode == 1 )
{
system->MakeFilePath(cur->request->item, cur->request->x_sendfile, is_thumb);
if( config->send_file_mode == 0 )
{
log << log3 << "Download: reading content of file: " << cur->request->x_sendfile << logend;
if( !GetBinaryFile(cur->request->x_sendfile, cur->request->out_bin_stream) )
{
log << log1 << "Download: I cannot read the content of the file: " << cur->request->x_sendfile << logend;
}
// IMPROVEME it would be good to set Content-Type header too
cur->request->x_sendfile.clear();
cur->request->send_bin_stream = true;
}
}
else
if( config->send_file_mode == 1 )
if( config->send_file_mode == 2 )
{
system->MakeRelativeFilePath(cur->request->item, config->send_file_relative_prefix, cur->request->x_sendfile, is_thumb);
}
else
{
log << log1 << "Download: send_file_mode in the config should be either 0 or 1" << logend;
log << log1 << "Download: send_file_mode in the config should be either 0, 1 or 2" << logend;
}
}