Get Presigned URL
Sprint 3
Get a presigned URL for accessing a file. Users can only access files under their own folder.
Endpoint
GET /api/v1/storage/objects/{object_name}/presigned-url
Headers
| Header | Required | Description |
|---|---|---|
Authorization | Yes | Bearer <access_token> |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
object_name | string (path) | Yes | Object name/path in bucket (must be within user's folder: organizations/{org_id}/files/{user_id}/) |
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
expires_seconds | integer | No | URL expiration time in seconds (default: 3600, min: 1, max: 604800) |
Response
Success (200)
{
"success": true,
"data": {
"url": "https://storage.example.com/bucket/organizations/1/files/123/report_20241203_101500_abc123.csv?X-Amz-Algorithm=...",
"expires_in_seconds": 3600
},
"message": "Presigned URL generated successfully"
}
Error Codes
| Status | Code | Description |
|---|---|---|
| 401 | UNAUTHORIZED | Invalid or missing authentication token |
| 403 | FORBIDDEN | Access denied - object_name must be within user's folder |
| 500 | INTERNAL_SERVER_ERROR | Failed to generate presigned URL |
Security
- Users can only access files under their own folder:
organizations/{org_id}/files/{user_id}/ - Path validation prevents directory traversal
- Configurable expiration time (1-604800 seconds)
Features
- Presigned URL for direct file access
- Configurable expiration time
- Default expiration: 1 hour (3600 seconds)
- Maximum expiration: 7 days (604800 seconds)
Example
curl -X GET "https://api.rivergen.com/api/v1/storage/objects/organizations/1/files/123/report_20241203_101500_abc123.csv/presigned-url?expires_seconds=7200" \
-H "Authorization: Bearer <access_token>"
Related Endpoints
- Get File Metadata - Get file metadata
- List Files - List files (includes presigned URLs)