Overview
DefDrive allows you to securely upload files to your personal storage space. Each upload is validated against your storage quota and file limits to ensure you stay within your allocated resources.Prerequisites
Before uploading files, ensure you have:- A valid authentication token
- Sufficient storage quota available
- Not exceeded your maximum file count limit
Storage Limits
Default user limits:
- Maximum files: 100 files
- Maximum storage: 1 GB (1,073,741,824 bytes)
models/user.go:14-15 for default values.
Upload Process
Authenticate your request
Include your authentication token in the request headers. The system validates your identity before processing the upload.
Prepare your file
Ensure your file doesn’t exceed remaining storage quota. The system checks both file count and total storage usage.
API Request Examples
Success Response
When a file is successfully uploaded, you’ll receive a response like:Error Responses
Storage Quota Exceeded
When you don’t have enough storage space:File Count Limit Exceeded
When you’ve reached your maximum file count:Duplicate File Name
When a file with the same name already exists in your directory:File Storage Location
Files are stored in a user-specific directory structure:Location field in the database stores the relative path: username/filename.ext (see controllers/file.go:102).
Checking Your Storage Usage
Before uploading, you can check your current usage:Implementation Details
The upload process performs the following validations (seecontrollers/file.go:24-122):
- Authentication check - Validates user session
- File count check - Ensures user hasn’t exceeded
MaxFileslimit - Storage check - Calculates current storage and validates new file fits within
MaxStorage - Directory creation - Creates user directory if it doesn’t exist
- Duplicate check - Prevents overwriting existing files
- File save - Saves file to disk and creates database record
All files are initially uploaded as private (
Public: false). Use the toggle public access endpoint to make files publicly accessible.Next Steps
- Creating Access Links - Generate shareable links for your uploaded files
- IP Subnet Restrictions - Restrict file access by IP or subnet
- One-Time Links - Create links that expire after single use