Overview
The Upload API allows you to upload files and generate secure download links with expiration, view limits, and password protection. Files are stored on the server and accessed through temporary secure links.Basic File Upload
Upload a file and receive a download link:Prepare the multipart request
Create a POST request to
/api/links/upload with the file as multipart/form-data:Request Parameters
TheLinkUploadRequestDto accepts the following form fields:
| Parameter | Type | Required | Validation | Description |
|---|---|---|---|---|
file | file | Yes | Must not be null | The file to upload |
expiresAt | string (ISO 8601) | No | Must be a future date/time | When the download link should expire |
maxViews | integer | No | Must be positive | Maximum number of downloads allowed |
password | string | No | - | Optional password protection |
All parameters except
file are optional. The file is uploaded as multipart/form-data.Advanced Examples
Upload with Expiration
Create a download link that expires after a specific date:Limited Downloads
Allow only a certain number of downloads:Password-Protected Upload
Require a password for downloading:X-Link-Password header when accessing the link. See Password Protection for details.
Complete Example with All Options
Combine expiration, download limits, and password protection:File Download Behavior
When a user accesses a file download link:- The server validates access permissions (password, expiration, view count)
- If valid, the file is returned with
Content-Disposition: attachmentheader - The browser prompts the user to download the file with its original filename
- The view count is incremented
Example Download Request
The
-L flag tells curl to follow redirects. The -o flag specifies the output filename.Error Handling
File Validation Errors
File Not Found on Download
If the file was deleted from the server:Access Denied Errors
See Password Protection and Link Expiration for access control error responses.Storage Considerations
File size limits
File size limits
Check your server configuration for maximum file upload size. By default, Spring Boot allows up to 1MB. You may need to configure
spring.servlet.multipart.max-file-size and spring.servlet.multipart.max-request-size for larger files.File retention
File retention
Uploaded files are stored on the server until:
- The link expires (if
expiresAtis set) - The link is manually revoked
- A cleanup process removes expired files
File naming
File naming
Original filenames are preserved and returned in the
Content-Disposition header during download. Ensure filenames don’t contain special characters that might cause issues.Security
Security
Files are stored on the server filesystem. Ensure proper file system permissions are set to prevent unauthorized access. Consider encrypting sensitive files at rest.
Best Practices
- Use expiration for all uploads: Set reasonable expiration times to prevent indefinite storage
- Limit download counts: For sensitive files, use
maxViewsto control distribution - Validate file types: Implement client-side validation before upload to improve UX
- Monitor storage usage: Track uploaded file sizes and implement cleanup policies
- Use passwords for sensitive data: Always password-protect confidential documents
- Communicate limits to users: Let users know expiration dates and download limits
Next Steps
Password Protection
Secure file downloads with passwords
Link Expiration
Configure when download links expire
Creating Links
Create links for external URLs
Revocation
Manually revoke download links
