Skip to main content

Storage API Overview

The Informer Storage API provides endpoints for managing file storage. Files can be uploaded, retrieved, and searched. All routes are prefixed with /api.

Features

  • File Upload - Upload files via multipart form data
  • File Retrieval - Get file metadata and download contents
  • File Search - Search files by filename

Authentication

All Storage API endpoints require authentication via session cookies or API tokens.

Endpoints

POST /api/files

Upload a new file.

Authentication: Required (session)

Request:

Multipart form data with file upload.

Form Fields:

FieldTypeRequiredDescription
filefileYesFile to upload (stream)

Example Request:

curl -X POST https://api.example.com/api/files \
-H "Cookie: session=..." \
-F "file=@document.pdf"

Response:

Returns the created file object with 201 Created status and Location header.

{
"id": "file-123",
"filename": "document.pdf",
"contentType": "application/pdf",
"size": 102400,
"createdAt": "2024-01-15T10:30:00Z",
"_links": {
"self": { "href": "/api/files/file-123" },
"inf:download": { "href": "/api/files/file-123/download" }
}
}

GET /api/files/{id}

Get file metadata.

Authentication: Required (session)

Response:

{
"id": "file-123",
"filename": "document.pdf",
"contentType": "application/pdf",
"size": 102400,
"embedded": false,
"createdAt": "2024-01-15T10:30:00Z",
"updatedAt": "2024-01-15T10:30:00Z",
"_links": {
"self": { "href": "/api/files/file-123" },
"inf:download": { "href": "/api/files/file-123/download" }
}
}

GET /api/files/{id}/download

Download file contents.

Authentication: Required (session)

Pre-blocks: file.lookup(params.id)

Response:

Returns file contents with appropriate Content-Type and Content-Disposition: attachment headers.

Example Response Headers:

Content-Type: application/pdf
Content-Disposition: attachment; filename="document.pdf"
Content-Length: 102400

GET /api/files

Search for files by filename.

Authentication: Required (session)

Query Parameters:

ParameterTypeDescription
filenamestringFilename to search for (partial match)

Example Request:

GET /api/files?filename=report

Response:

{
"_links": {
"self": { "href": "/api/files" }
},
"_embedded": {
"inf:file": [
{
"id": "file-123",
"filename": "monthly-report.pdf",
"contentType": "application/pdf",
"size": 102400,
"createdAt": "2024-01-15T10:30:00Z",
"_embedded": {
"inf:owner": {
"username": "john",
"displayName": "John Doe",
"_links": {
"self": { "href": "/api/users/john" }
}
}
},
"_links": {
"self": { "href": "/api/files/file-123" }
}
},
{
"id": "file-456",
"filename": "quarterly-report.xlsx",
"contentType": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"size": 51200,
"createdAt": "2024-01-14T14:22:00Z"
}
]
},
"start": 0,
"count": 2,
"total": 2
}

File Properties

PropertyTypeDescription
idstringUnique file identifier
filenamestringOriginal filename
contentTypestringMIME type
sizeintegerFile size in bytes
embeddedbooleanWhether file is embedded in another entity
rolestringFile role (for template files: TEMPLATE, ASSET, DATA)
templateIdstringAssociated template ID (if embedded)
datasetIdstringAssociated dataset ID (if embedded)
createdAtstringISO 8601 creation timestamp
updatedAtstringISO 8601 last update timestamp

Use Cases

Upload User Document

POST /api/files
Content-Type: multipart/form-data

file=@user-guide.pdf

Download File

GET /api/files/file-123/download

Search for Reports

GET /api/files?filename=report

Notes

  • Files can be standalone or embedded in other entities (templates, datasets, etc.)
  • Embedded files are managed through their parent entity's API
  • File upload supports streaming for large files
  • Downloaded files include original filename in Content-Disposition header