Skip to content

[BUG]The uploaded file cannot be saved locally #270

Closed

Description

@XinHengW

Prerequisites

Description

[Description of the issue]

Steps to Reproduce

  1. [First Step]
  2. [Second Step]
  3. [and so on...]

Expected behavior: [What you expect to happen]

Actual behavior: [What actually happens]

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).
  • provide a main that reproduces the error.

Activity

  1. added
    bugConfirmed bugs or reports that are very likely to be bugs.
    on May 19, 2022
  2. etr commented on May 19, 2022

    @etr
    Owner

    Can you provide more details on the issue and how to reproduce. Filling the template above helps as well.

  3. XinHengW commented on May 24, 2022

    @XinHengW
    Author

    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

    thanks!!!!!

  4. LeSpocky commented on May 24, 2022

    @LeSpocky
    Contributor

    Run httpserver and upload files by post. After uploading, the uploaded files will be automatically deleted by httpserver.

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugConfirmed bugs or reports that are very likely to be bugs.

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions