Skip to content

Commit fdb5d90

Browse files
committed
feat: add proxy endpoint for serving static files from Google Cloud Storage
1 parent 9837809 commit fdb5d90

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,49 @@ Returns a JSON object with the following schema:
500500
]
501501
```
502502
503+
### `GET /static/*`
504+
505+
Proxy endpoint to serve files from the private Google Cloud Storage bucket. The request path after `/v1/static/` maps directly to the GCS object path.
506+
507+
#### Static File Features
508+
509+
- **Conditional Requests**: Supports `If-None-Match` header for cache validation (returns 304 if unchanged)
510+
- **Content Type Detection**: Automatically detects MIME type based on file extension
511+
- **Streaming**: Files are streamed directly from GCS for efficient memory usage
512+
- **ETag Support**: Returns ETag header for cache validation
513+
514+
#### Supported File Types
515+
516+
| Extension | MIME Type |
517+
|-----------|-----------|
518+
| `.json` | `application/json` |
519+
| `.js` | `application/javascript` |
520+
| `.png` | `image/png` |
521+
| `.svg` | `image/svg+xml` |
522+
| `.csv` | `text/csv` |
523+
| `.pdf` | `application/pdf` |
524+
525+
#### Static File Response
526+
527+
```bash
528+
curl --request GET \
529+
--url 'https://{{HOST}}/v1/static/reports/2023/example.json'
530+
```
531+
532+
Returns the file content with appropriate headers:
533+
534+
```http
535+
Content-Type: application/json
536+
ETag: "abc123..."
537+
Content-Length: 1234
538+
```
539+
540+
#### Error Responses
541+
542+
- **400 Bad Request**: Invalid file path (e.g., contains `..` or `//`)
543+
- **404 Not Found**: File does not exist in the bucket
544+
- **500 Internal Server Error**: Failed to retrieve or stream the file
545+
503546
## Testing
504547
505548
```bash

0 commit comments

Comments
 (0)