A simple FastAPI service for uploading files and retrieving them via direct links.
- Upload files via POST endpoint
- Get direct download links for uploaded files
- Retrieve file metadata
- Health check endpoint
POST /upload
Content-Type: multipart/form-data
# Returns:
{
"filename": "document.pdf",
"original_filename": "document.pdf",
"download_url": "/document.pdf",
"size": 12345
}GET /{filename}
# Example: GET /document.pdf
# Returns the file for download/viewing
# Access directly via: domain-name/document.pdfGET /file/{filename}/info
# Example: GET /file/document.pdf/info
# Returns file metadata without downloadingGET /health
# Returns: {"status": "healthy"}docker build -t upload-files-service .docker run -p 8000:8000 -v $(pwd)/uploads:/app/uploads upload-files-service- API: http://localhost:8000
- Interactive docs: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
curl -X POST "http://localhost:8000/upload" \
-F "file=@/path/to/your/file.pdf"# After uploading "document.pdf", access it directly:
curl -O "http://localhost:8000/document.pdf"
# Or open in browser:
# http://localhost:8000/document.pdfcurl "http://localhost:8000/file/document.pdf/info"- Files are stored in
/app/uploadsinside the container - File metadata is stored in memory (use a database for production)
- The service uses UUIDs for file identification