'Generic Commit'
All checks were successful
Build-Test-Publish / build (linux/amd64) (push) Successful in 1m20s
Build-Test-Publish / build (linux/arm64) (push) Successful in 2m1s
Build-Test-Publish / create-manifest (push) Successful in 14s

This commit is contained in:
Your Name
2025-06-15 16:37:57 +12:00
parent a4d9e3ebb5
commit bf9f714a3d
4 changed files with 47 additions and 14 deletions

View File

@@ -8,8 +8,9 @@ Simple Object Server is a C++23 application that provides a REST API for storing
- File storage with deduplication using content hashing - File storage with deduplication using content hashing
- Metadata management with label:tag system - Metadata management with label:tag system
- Token-based authentication for write operations - Token-based authentication for write operations
- Support for large file uploads - Support for large file uploads (up to 6GB)
- CORS and rate limiting support - CORS and rate limiting support
- High-performance HTTP handling with Drogon framework
## Common Development Commands ## Common Development Commands
@@ -45,9 +46,10 @@ Simple Object Server is a C++23 application that provides a REST API for storing
### Key Components ### Key Components
1. **HTTP Server (src/server.cpp/hpp)** 1. **HTTP Server (src/server.cpp/hpp)**
- Uses httplib for HTTP handling - Uses Drogon framework for high-performance HTTP handling
- Implements all REST endpoints - Implements all REST endpoints via HttpController
- Handles authentication, CORS, and rate limiting - Handles authentication, CORS, and rate limiting
- Supports large file uploads (up to 6GB) with efficient streaming
2. **Database Layer (src/database.cpp/hpp)** 2. **Database Layer (src/database.cpp/hpp)**
- SQLite-based metadata storage - SQLite-based metadata storage
@@ -55,7 +57,8 @@ Simple Object Server is a C++23 application that provides a REST API for storing
- Manages label:tag uniqueness and versioning - Manages label:tag uniqueness and versioning
3. **Request Handlers** 3. **Request Handlers**
- `put_handler.cpp/hpp`: File upload logic with deduplication - `HttpController.cpp/hpp`: Drogon HTTP controller for route handling
- `put_handler.cpp/hpp`: File upload logic with deduplication and streaming support
- `update_handler.cpp/hpp`: Metadata update functionality - `update_handler.cpp/hpp`: Metadata update functionality
4. **Utilities** 4. **Utilities**
@@ -73,6 +76,7 @@ Simple Object Server is a C++23 application that provides a REST API for storing
### Build System ### Build System
- Uses CMake with C++23 standard - Uses CMake with C++23 standard
- Drogon framework statically linked for high performance
- Docker-based build process for consistency across platforms - Docker-based build process for consistency across platforms
- Static linking for standalone executables - Static linking for standalone executables
- Multi-architecture support (linux/amd64, linux/arm64, windows/amd64) - Multi-architecture support (linux/amd64, linux/arm64, windows/amd64)
@@ -86,6 +90,7 @@ The test suite (`testing/test.sh`) covers:
4. File deletion 4. File deletion
5. Rate limiting functionality 5. Rate limiting functionality
6. MD5 checksum verification 6. MD5 checksum verification
7. Large file upload testing (1GB files)
Tests use curl for API interactions and jq for JSON parsing. Tests use curl for API interactions and jq for JSON parsing.
@@ -97,4 +102,23 @@ The server uses JSON configuration (`sos_config.json`) with these key settings:
- `cors`: CORS policy configuration - `cors`: CORS policy configuration
- `rate_limiting`: Auth attempt limits - `rate_limiting`: Auth attempt limits
Default configuration is suitable for Docker deployment with storage at `/data/storage`. Default configuration is suitable for Docker deployment with storage at `/data/storage`.
## Architecture Notes
### HTTP Framework Migration
The server has been migrated from httplib to Drogon for improved performance and scalability:
- **Previous**: Used cpp-httplib (single-header library)
- **Current**: Uses Drogon framework with async request handling
- **Benefits**: Better performance, larger file support, thread-safe operation
- **Compatibility**: Full API compatibility maintained during migration
### Performance Characteristics
- **Large File Support**: Efficiently handles files up to 6GB
- **Memory Management**: Streaming file processing to minimize memory usage
- **Deduplication**: Content-based deduplication reduces storage requirements
- **Thread Safety**: Singleton pattern with proper mutex protection
- **Security**: Request size limits and rate limiting prevent abuse

View File

@@ -18,9 +18,12 @@ curl https://getbin.xyz/simple-object-server-install | bash
- Delete files by hash - Delete files by hash
- List all stored objects - List all stored objects
- Automatic file deduplication using content hashing - Automatic file deduplication using content hashing
- Support for large file uploads - Support for large file uploads (up to 6GB)
- High-performance HTTP server with async request handling
- Configurable storage location and server settings - Configurable storage location and server settings
- Token-based authentication for write operations - Token-based authentication for write operations
- CORS support for web applications
- Rate limiting for security
## Building ## Building
@@ -278,14 +281,20 @@ CREATE TABLE objects (
## Testing ## Testing
The repository includes two test scripts: The repository includes comprehensive test scripts:
- `test.sh`: Basic functionality tests - `test.sh`: Complete test suite including basic functionality, metadata preservation, tag versioning, rate limiting, and 1GB file upload tests
- `test_1GB_file_upload.sh`: Tests uploading and downloading a 1GB file - `testing/test.sh`: Direct test script for integration testing
- `testing/test_1GB_file_upload.sh`: Standalone 1GB file upload test
To run the tests: To run the full test suite:
```bash ```bash
./test.sh ./test.sh
./test_1GB_file_upload.sh ```
To run individual tests:
```bash
./testing/test.sh
./testing/test_1GB_file_upload.sh
``` ```
## License ## License

View File

@@ -51,7 +51,7 @@ void PutHandler::handle_put_object(const drogon::HttpRequestPtr& req, std::funct
if (!contentLengthHeader.empty()) { if (!contentLengthHeader.empty()) {
try { try {
size_t contentLength = std::stoull(contentLengthHeader); size_t contentLength = std::stoull(contentLengthHeader);
const size_t MAX_UPLOAD_SIZE = 2ULL * 1024 * 1024 * 1024; // 2GB const size_t MAX_UPLOAD_SIZE = 6ULL * 1024 * 1024 * 1024; // 6GB
if (contentLength > MAX_UPLOAD_SIZE) { if (contentLength > MAX_UPLOAD_SIZE) {
resp->setStatusCode(drogon::k413RequestEntityTooLarge); resp->setStatusCode(drogon::k413RequestEntityTooLarge);
nlohmann::json response = {{"result", "error"}, {"error", "File too large"}}; nlohmann::json response = {{"result", "error"}, {"error", "File too large"}};

View File

@@ -146,8 +146,8 @@ bool Server::start() {
drogon::app().addListener(config_.host, config_.port); drogon::app().addListener(config_.host, config_.port);
drogon::app().setThreadNum(16); drogon::app().setThreadNum(16);
// Set security limits (allowing for 1GB+ files for testing) // Set security limits (allowing for large files up to 6GB)
drogon::app().setClientMaxBodySize(2ULL * 1024 * 1024 * 1024); // 2GB max body size drogon::app().setClientMaxBodySize(6ULL * 1024 * 1024 * 1024); // 6GB max body size
drogon::app().setClientMaxMemoryBodySize(100 * 1024 * 1024); // 100MB max memory body (keep this lower) drogon::app().setClientMaxMemoryBodySize(100 * 1024 * 1024); // 100MB max memory body (keep this lower)
drogon::app().enableGzip(true); // Enable compression drogon::app().enableGzip(true); // Enable compression