Overview
Access links provide a secure way to share files with others without requiring them to have a DefDrive account. Each access link is a unique MD5-style hash that grants access to a specific file with configurable restrictions.Access Link Structure
Access links are 32-character hexadecimal strings that look like MD5 hashes:controllers/access.go:26-39).
Creating an Access Link
Identify your file
Get the file ID from your uploaded files. You must own the file to create access links for it.
Configure access settings
Decide on restrictions: IP allowlists, subnet restrictions, expiration, one-time use, and TTL settings.
API Request
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | No | Human-readable identifier for the access link |
public | boolean | Yes | Must be true for link to be accessible |
ips | string[] | No | Array of allowed IP addresses |
subnets | string[] | No | Array of allowed CIDR subnets |
expires | string | No | RFC3339 timestamp for link expiration |
oneTimeUse | boolean | No | If true, link becomes invalid after first use |
enableTTL | boolean | No | Enable TTL-based access limitation |
ttl | integer | No | Number of times link can be accessed (when enableTTL is true) |
All access control fields are defined in
models/access.go:7-22. The public flag must be true for the link to be accessible.Success Response
link field provides the complete URL ready to share with users.
Link Generation Process
The system generates unique access links using the following process (seecontrollers/access.go:26-39):
- Create MD5 hash from UUID + current timestamp
- Check database for collision
- If collision exists, regenerate
- Return unique 32-character hexadecimal string
Public Access Requirement
This dual-flag system is enforced inmiddleware/access_restrictions.go:37-41:
Managing Access Links
List All Access Links for a File
Update an Access Link
Delete an Access Link
Authorization
Access link operations require ownership verification (seecontrollers/access.go:55-65):
- System verifies you own the file
- Only file owners can create, update, or delete access links
- Attempting to manage another user’s file access returns
403 Forbidden
Error Responses
File Not Found
Unauthorized Access
Invalid Request Body
Environment Configuration
The full access URL is constructed using theHOST_URL environment variable (see controllers/access.go:106-111):
Next Steps
- IP Subnet Restrictions - Restrict access by network location
- TTL Configuration - Limit the number of times a link can be used
- One-Time Links - Create single-use access links