Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/uploadthing/.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ http {
server_name 1-E-17.42heilbronn.de localhost;
root /examples/uploadthing;
index /index.html;
client_max_body_size 1024k;
client_max_body_size 1024m;
client_body_buffer_size 1024k;
client_header_buffer_size 1024k;
upload_dir /uploads;
Expand Down
15 changes: 9 additions & 6 deletions src/http/RequestHandler/PostRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
/* ::: :::::::: */
/* PostRequest.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: flfische <flfische@student.42heilbronn. +#+ +:+ +#+ */
/* By: lgreau <lgreau@student.42heilbronn.de> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/11 14:43:11 by flfische #+# #+# */
/* Updated: 2025/01/16 20:26:16 by flfische ### ########.fr */
/* Updated: 2025/01/17 17:01:15 by lgreau ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -122,13 +122,16 @@ HttpResponse RequestHandler::handleFileUpload(const std::string &part, const std
LOG_ERROR("Invalid part: " + part);
return buildDefaultResponse(Http::BAD_REQUEST);
}
if (!_matchedRoute.getUploadDir().empty())
filename = buildpath(_matchedRoute.getUploadDir(), filename, _serverConfig.getRoot());
else {
if (!_matchedRoute.getUploadDir().empty()) {
if (!_matchedRoute.getRoot().empty())
filename = buildpath(_matchedRoute.getUploadDir(), filename, _matchedRoute.getRoot());
else
filename = buildpath(_matchedRoute.getUploadDir(), filename, _serverConfig.getRoot());
} else {
if (!_serverConfig.getUploadDir().empty())
filename = buildpath(_serverConfig.getUploadDir(), filename, _serverConfig.getRoot());
else
filename = buildpath(_serverConfig.getRoot(), filename, _serverConfig.getRoot());
return buildDefaultResponse(Http::FORBIDDEN);
}
std::ofstream file(filename, std::ios::binary);
if (!file.is_open()) {
Expand Down
Loading