API Reference
All API endpoints are relative to your server base URL. No authentication required.
📡 Base URL
https://your-domain.com/api/resourcesEndpoints
GET
/api/resourcesList all directories and files at the given path. Use this to navigate the resource library hierarchy.
Query Parameters
pathstringoptionalDirectory path to list. Defaults to root (/). Example: /logos/2026Response
{
"path": "/logos/2026",
"dirs": [
{ "name": "dark", "path": "logos/2026/dark" }
],
"files": [
{
"name": "company-logo.png",
"path": "logos/2026/company-logo.png",
"type": "image",
"url": "/resources/logos/2026/company-logo.png",
"size": 45312
}
]
}Example
fetch('/api/resources?path=/logos/2026')
.then(r => r.json())
.then(data => console.log(data.files));POST
/api/resourcesUpload a new resource to the library. The file is stored at the specified path on the server.
Request Body (multipart/form-data)
fileFileThe image or video file to uploadpathstringoptionalDirectory path to store the file in. Defaults to /. Example: /logos/2026namestringoptionalCustom filename (without extension). If omitted, original filename is used.Response
{
"url": "/resources/logos/2026/company-logo.png",
"path": "/logos/2026",
"name": "company-logo.png"
}Example
const fd = new FormData();
fd.append('file', fileInput.files[0]);
fd.append('path', '/logos/2026');
fd.append('name', 'company-logo');
const res = await fetch('/api/resources', { method: 'POST', body: fd });
const { url } = await res.json();
console.log('Uploaded to:', url);GET
/api/resources/[...path]Retrieve and stream a specific resource file by its full path. Returns the file with appropriate Content-Type headers.
Query Parameters
pathstring[]Full path segments to the file. Example: /api/resources/logos/2026/company-logo.pngResponse
Binary file content with Content-Type header set appropriately (e.g. image/png, video/mp4)
Example
// Use directly in HTML — served via public/resources/ or API route:
<img src="/api/resources/logos/2026/company-logo.png" alt="Logo" />
// Or fetch the raw bytes:
const res = await fetch('/api/resources/logos/2026/company-logo.png');
const blob = await res.blob();📝 Notes
- Resources are stored in
public/resources/and are also served as static files directly (faster than API route) - Path traversal (
..) is stripped automatically - Supported image formats: JPG, PNG, GIF, WebP, SVG, AVIF, BMP, TIFF
- Supported video formats: MP4, MOV, WebM, AVI, MKV, M4V
- No file size limit is enforced by the API — configure limits at server/proxy level