Skip to main content

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

HeaderRequiredDescription
AuthorizationYesBearer <access_token>

Path Parameters

ParameterTypeRequiredDescription
object_namestring (path)YesObject name/path in bucket (must be within user's folder: organizations/{org_id}/files/{user_id}/)

Query Parameters

ParameterTypeRequiredDescription
expires_secondsintegerNoURL 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

StatusCodeDescription
401UNAUTHORIZEDInvalid or missing authentication token
403FORBIDDENAccess denied - object_name must be within user's folder
500INTERNAL_SERVER_ERRORFailed 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>"