You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG]The uploaded file cannot be saved locally #270
Reproduces how often: [What percentage of the time does it reproduce?]
Versions
OS version (if on linux, the output of "uname -a")
libhttpserver version (please specify whether compiled or packaged)
libmicrohttpd version (please specify whether compiled or packaged)
If you have problems during build:
Compiler version
autotools version
Additional Information
Any additional information, configuration (especially build configuration flags if you compiled the libraries) or data that might be necessary to reproduce the issue.
If you have problems during build, please attach your config.log and the full scope of your error from make.
If you have problems at execution, please:
attach the stacktrace in case of crash (a coredump would be even better).
Run httpserver and upload files by post. After uploading, the uploaded files will be automatically deleted by httpserver.
After changing the code like this: MHD_Result webserver::complete_request(MHD_Connection* connection, struct details::modded_request* mr, const char* version, const char* method) { mr->ws = this; mr->dhr->set_path(mr->standardized_url->c_str()); mr->dhr->set_method(method); mr->dhr->set_version(version); /*I changed!*/ _http::file_info& file = mr->dhr->get_or_create_file_info(mr->upload_key,mr->upload_filename); std::string real_name =mr->ws->file_upload_dir + "/" + mr->upload_filename; rename(file.get_file_system_file_name().data(),real_name.data());_ /*end*/ return finalize_answer(connection, mr, method); }
The file can be saved under its real name.
When the "rename()" function is commented out, no files can be saved.
step of reproduce:
1 run httpserver /home/data
2 upload "test.txt" by postman
3 can't find any file uploaded
Activity
etr commentedon May 19, 2022
Can you provide more details on the issue and how to reproduce. Filling the template above helps as well.
XinHengW commentedon May 24, 2022
Run httpserver and upload files by post. After uploading, the uploaded files will be automatically deleted by httpserver.
After changing the code like this:
MHD_Result webserver::complete_request(MHD_Connection* connection, struct details::modded_request* mr, const char* version, const char* method) { mr->ws = this; mr->dhr->set_path(mr->standardized_url->c_str()); mr->dhr->set_method(method); mr->dhr->set_version(version); /*I changed!*/ _http::file_info& file = mr->dhr->get_or_create_file_info(mr->upload_key,mr->upload_filename); std::string real_name =mr->ws->file_upload_dir + "/" + mr->upload_filename; rename(file.get_file_system_file_name().data(),real_name.data());_ /*end*/ return finalize_answer(connection, mr, method); }The file can be saved under its real name.
When the "rename()" function is commented out, no files can be saved.
step of reproduce:
1 run
httpserver /home/data2 upload "test.txt" by postman
3 can't find any file uploaded
thanks!!!!!
LeSpocky commentedon May 24, 2022
There was a lengthy discussion about this in #264 and the actual behavior you probably experienced, was implemented with #266.
Short term solution: if you need the file to be persistent, copy it in your request handler to some place of your choice.
Long term solution: propose something to properly solve #264.
Add file cleanup callback for uploaded files (issues #264, #270)
Add file cleanup callback for uploaded files (issues #264, #270) (#356)