Skip to main content

Delete File

Sprint 3

Delete a file from storage and update quota. Users can only delete files under their own folder.

Endpoint

DELETE /api/v1/storage/objects/{object_name}

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}/)

Response

Success (200)

{
"success": true,
"data": {
"object_name": "organizations/1/files/123/report_20241203_101500_abc123.csv"
},
"message": "File deleted successfully"
}

Error Codes

StatusCodeDescription
401UNAUTHORIZEDInvalid or missing authentication token
403FORBIDDENAccess denied - object_name must be within user's folder
404NOT_FOUNDFile not found
500INTERNAL_SERVER_ERRORFailed to delete file

Security

  • Users can only delete files under their own folder: organizations/{org_id}/files/{user_id}/
  • Path validation prevents directory traversal
  • Object name must start with user's allowed path prefix

Features

  • Deletes file from storage
  • Automatically updates quota
  • Records deletion in storage_files table
  • Organization-scoped access control

Important Notes

  • Quota is automatically updated after deletion
  • If file is not found in tracking table, deletion from storage is still attempted
  • Deletion is permanent and cannot be undone

Example

curl -X DELETE "https://api.rivergen.com/api/v1/storage/objects/organizations/1/files/123/report_20241203_101500_abc123.csv" \
-H "Authorization: Bearer <access_token>"