Working With Files

Files are addressed by the path after /files/. Listing uses the path after /list/ as a prefix filter.

Upload a File

1curl -X PUT "https://api.hola.cloud/v1/buckets/bucket-550e8400-e29b-41d4-a716-446655440000/files/notes/readme.txt" \
2  -H 'X-Glue-Authentication: {"user":{"id":"user-123"}}' \
3  -H "Content-Type: text/plain" \
4  --data-binary @readme.txt

Response:

 1{
 2  "id": "file-9f0b7b3c-1d2e-4a5f-8b9c-0123456789ab",
 3  "uuid": "9f0b7b3c-1d2e-4a5f-8b9c-0123456789ab",
 4  "created_timestamp": 1782045660000000000,
 5  "updated_timestamp": 1782045660000000000,
 6  "owners": ["user-123"],
 7  "status": "available",
 8  "size": 24576,
 9  "name": "notes/readme.txt",
10  "bucket": "bucket-550e8400-e29b-41d4-a716-446655440000",
11  "hash_md5": "example-md5",
12  "hash_sha256": "example-sha256",
13  "mime_type": "text/plain; charset=utf-8"
14}

Download a File

1curl "https://api.hola.cloud/v1/buckets/bucket-550e8400-e29b-41d4-a716-446655440000/files/notes/readme.txt" \
2  -H 'X-Glue-Authentication: {"user":{"id":"user-123"}}' \
3  -o readme.txt

The response body is the stored file content. Content-Type is set from the stored mime_type.

Get File JSON Metadata

Use ?metadata on the download endpoint to return the file object as JSON.

1curl "https://api.hola.cloud/v1/buckets/bucket-550e8400-e29b-41d4-a716-446655440000/files/notes/readme.txt?metadata" \
2  -H 'X-Glue-Authentication: {"user":{"id":"user-123"}}'

List Files

1curl "https://api.hola.cloud/v1/buckets/bucket-550e8400-e29b-41d4-a716-446655440000/list/notes/" \
2  -H 'X-Glue-Authentication: {"user":{"id":"user-123"}}'

Response:

 1[
 2  {
 3    "id": "file-9f0b7b3c-1d2e-4a5f-8b9c-0123456789ab",
 4    "name": "notes/readme.txt",
 5    "bucket": "bucket-550e8400-e29b-41d4-a716-446655440000",
 6    "created_timestamp": 1782045660000000000,
 7    "updated_timestamp": 1782045660000000000,
 8    "size": 24576,
 9    "mime_type": "text/plain; charset=utf-8",
10    "hash_md5": "example-md5",
11    "hash_sha256": "example-sha256",
12    "status": "available",
13    "owners": ["user-123"]
14  }
15]

HEAD File

1curl -I "https://api.hola.cloud/v1/buckets/bucket-550e8400-e29b-41d4-a716-446655440000/files/notes/readme.txt" \
2  -H 'X-Glue-Authentication: {"user":{"id":"user-123"}}'

The handler sets Last-Modified and Content-Length.

Delete a File

1curl -X DELETE "https://api.hola.cloud/v1/buckets/bucket-550e8400-e29b-41d4-a716-446655440000/files/notes/readme.txt" \
2  -H 'X-Glue-Authentication: {"user":{"id":"user-123"}}'

Comments

Leave a comment