drogonframework / drogon

Drogon: A C++14/17/20 based HTTP web application framework running on Linux/macOS/Unix/Windows
MIT License
11.65k stars 1.12k forks source link

attempt to create uploads directory #2161

Closed alex-lt-kong closed 2 months ago

alex-lt-kong commented 2 months ago

Just incoporated Drogon into my program, works like a charm, but i noticed that Drogon appears to attempt to create a ./uploads/ directory and many of its sub-directories. (the attempts failed because the program does not have write permission) Is this expected?:

20240917 14:21:12.472984 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/00/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473051 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/01/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473076 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/02/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473099 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/03/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473121 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/04/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473141 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/05/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473165 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/06/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473189 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/07/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473212 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/08/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473237 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/09/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473262 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/0A/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473285 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/0B/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473309 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/0C/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473334 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/0D/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473359 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/0E/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473383 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/0F/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473406 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/10/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473430 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/11/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473454 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/12/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473477 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/13/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473501 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/14/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473527 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/15/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473554 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/16/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473579 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/17/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473603 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/18/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473627 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/19/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473683 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/1A/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473719 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/1B/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473744 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/1C/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473767 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/1D/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473792 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/1E/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473816 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/1F/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473842 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/20/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473868 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/21/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473894 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/22/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473919 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/23/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473946 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/24/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473970 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/25/: Permission denied - Utilities.cc:1133
20240917 14:21:12.473992 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/26/: Permission denied - Utilities.cc:1133
20240917 14:21:12.474016 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/27/: Permission denied - Utilities.cc:1133
20240917 14:21:12.474040 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/28/: Permission denied - Utilities.cc:1133
20240917 14:21:12.474062 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/29/: Permission denied - Utilities.cc:1133
20240917 14:21:12.474084 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/2A/: Permission denied - Utilities.cc:1133
20240917 14:21:12.474108 UTC 1525 ERROR Error 13 creating path ./uploads/tmp/2B/: Permission denied - Utilities.cc:1133

... many more lines omitted

Below is the function used to invoke a Drogon instance:

app()
  .setLogPath("")
  .setLogLevel(trantor::Logger::kWarn)
  .addListener("127.0.0.1", 8080)
  .setThreadNum(4)
  .disableSigtermHandling()
  .registerHandler(
      "device_info/?deviceId={deviceId}",
      [](__attribute__((unused)) const HttpRequestPtr &req,
         std::function<void(const HttpResponsePtr &)> &&callback,
         const size_t deviceId) {
        drogon::HttpResponsePtr resp;
        // business logic
        callback(resp);
      },
      {Get, "Realtime CCTV"})
  .run();
an-tao commented 2 months ago

These temporary directories are used to store requests larger than client_max_body_size, which are then mapped into memory using mmap for user processing. This approach is to handle the physical memory consumption caused by large requests during high concurrency

alex-lt-kong commented 2 months ago
an-tao commented 2 months ago

You can change the upload directory in the configuration file. It can't be turned off currently.