Files

This endpoint provides comprehensive file management capabilities, including uploading, downloading, and retrieving file metadata.

Upload

To upload a file, send a POST request to /files/upload with the file as a form-data field named file. The server responds with a 201 Created status code and returns a FileRecord object containing the file’s metadata.

Files are stored in the system for at least 7 days by default. For permanent storage, attach the file to a database record by referencing the file’s URL in supported attributes of your database models.

Download

To download a file, send a GET request to /files/:file_id. The response contains the file with appropriate content-type and content-length headers.

Public download

This feature is not implemented yet. Authentication is currently required for all file downloads.

Image and Video Variants

For image and video files, you can request optimized variants by sending a GET request to /files/:file_id/:variant. This is useful for displaying thumbnails or responsive images based on device requirements.

Available image variants:

All variant sizes (except ‘original’ and ‘avif’) are returned in the AVIF format for optimal compression. The ‘original’ variant preserves the uploaded format, while ‘avif’ converts the original dimensions to AVIF format.

Endpoints


get/api/v3/files/(:variant/)?:file_id

Download a file with optional variant selection for images and videos.

This endpoint streams the requested file directly to the client with appropriate content-type and content-length headers. For images and videos, you can request specific variants optimized for different use cases.

Available Variants

If no variant is specified, the original variant is returned by default.

Input Schema

object
file_id: string
variant?: string or null

Typescript

type InputSchema = { file_id: string; variant?: string | null };


get/api/v3/files/info/:file_id

Retrieve detailed information and metadata about a file.

This endpoint returns comprehensive metadata about the specified file, including:

This is useful when you need file information without downloading the actual file content.

Input Schema

object
file_id: integer

Typescript

type InputSchema = { file_id: number };

Output Schema

object
data:
object
type: string
id?: string
attributes?:
object
id?: integer
size?: string
mime_type?: string
public?: boolean
created_by?: integer
created_role?: string
created_at?: datetime
path?: string
relationships?: open struct
included?:
array
Elements: open struct

Typescript

type OutputSchema = {
  data: {
    type: string;
    id?: string;
    attributes?: {
      id?: number;
      size?: string;
      mime_type?: string;
      public?: boolean;
      created_by?: number;
      created_role?: string;
      created_at?: Date;
      path?: string;
    };
    relationships?: Record<string, any>;
  };
  included?: Array<Record<string, any>>;
};


post/api/v3/files/upload

Upload a file to the Pulse system.

This endpoint accepts file uploads and stores them in the system. Files are retained for at least 7 days by default. To ensure permanent storage, attach the file to a database record after upload.

Technical Details

Input Schema

object
The file to upload
file:
object
filename?: string
type?: string
name?: string
tempfile: unknown
head?: string

Typescript

type InputSchema = {
  // The file to upload
  file: {
    filename?: string;
    type?: string;
    name?: string;
    tempfile: any;
    head?: string;
  };
};

Output Schema

object
data:
object
type: string
id?: string
attributes?:
object
id?: integer
size?: string
mime_type?: string
public?: boolean
created_by?: integer
created_role?: string
created_at?: datetime
path?: string
relationships?: open struct
included?:
array
Elements: open struct

Typescript

type OutputSchema = {
  data: {
    type: string;
    id?: string;
    attributes?: {
      id?: number;
      size?: string;
      mime_type?: string;
      public?: boolean;
      created_by?: number;
      created_role?: string;
      created_at?: Date;
      path?: string;
    };
    relationships?: Record<string, any>;
  };
  included?: Array<Record<string, any>>;
};