OdbDesign
OdbDesign ODB++ Parser - C++ library, gRPC/REST server, CLI, tests
 
Loading...
Searching...
No Matches
FileUploadController.h
Go to the documentation of this file.
1#pragma once
2
4#include "App/IOdbServerApp.h"
5#include <optional>
6#include <string>
7
8namespace Odb::App::Server
9{
11 {
12 public:
14
15 void register_routes() override;
16
17 private:
18 crow::response handleOctetStreamUpload(const std::string& filename, const crow::request& req);
19 crow::response handleMultipartFormUpload(const crow::request& req);
20
21 // Security-audit F002: reject upload filenames that are not a single
22 // safe component (separators, traversal, rooted/drive forms, control
23 // characters, trailing dots/spaces, over-length). Returns nullopt for
24 // rejected names - callers must fail the request, never launder it.
25 std::optional<std::string> sanitizeFilename(const std::string& filename) const;
26
27 constexpr static const inline char MULTIPART_FORM_DATA_PART_NAME[] = "file";
28 constexpr static const inline char MULTIPART_FORM_DATA_PART_FILENAME[] = "filename";
29 constexpr static const inline char CONTENT_DISPOSITION_HEADER_NAME[] = "Content-Disposition";
30 constexpr static const inline char CONTENT_TYPE_HEADER_NAME[] = "Content-Type";
31 constexpr static const inline char CONTENT_TYPE_MULTIPART_FORM_DATA[] = "multipart/form-data";
32 constexpr static const inline char CONTENT_TYPE_APPLICATION_OCTET_STREAM[] = "application/octet-stream";
33
34
35 //constexpr static const inline char MULTIPART_FORMDATA_PART_NAME[] = "InputFile"
36
37 };
38}
39