$files
Updated on Aug 25, 2025 5 minutes to readThe Files Plugin provides a set of methods to manage, upload, download, and manipulate files in the application.
Methods
Method | Description |
---|---|
convert | Converts a file to a different format. |
getAsBase64 | Returns the Base64 string of a file if available. |
getDownloadUrl | Returns the URL to download a file. |
getInfo | Returns detailed information about a file. |
getPublicUrl | Returns the public URL of a file. |
getThumbnailUrl | Returns the URL of a file thumbnail. |
makePrivate | Sets a file to private. |
makePublic | Sets a file to public. |
saveAsBase64 | Saves a file as Base64 and returns FileInfo. |
saveUploadedFile | Saves an uploaded file and returns FileInfo. |
Methods Details
convert()
• Type
(
id: string | UploadedFile,
format: ConvertFormat,
options?: object
) => FileInfo | null;
// Overload 1: PNG conversion
(
id: string | UploadedFile,
format: 'png',
options?: { page?: number, dpi?: number },
) => FileInfo | null;
// Overload 2: PDF conversion
(
id: string | UploadedFile,
format: 'pdf',
options?: { startPage?: number, endPage?: number, version?: string },
) => FileInfo | null;
• Details
Overload 1:
Expects a file ID or UploadedFile object and the format 'png'.
Optional options may include:
– page → page number to convert (for multi-page documents).
– dpi → resolution for the output image.
Overload 2:
Expects a file ID or UploadedFile object and the format 'pdf'.
Optional options may include:
– startPage → first page to include in the PDF.
– endPage → last page to include in the PDF.
– version → PDF version to generate.
Returns a FileInfo object or null
if conversion fails.
getAsBase64()
• Type
(id: string) => string | null
• Details
Expects a file ID.
Returns the Base64 string of the file, or null
if the file is not found.
getDownloadUrl()
• Type
(
id: string,
schema?: boolean,
params?: BaseFileParams
) => string
• Details
Expects a file ID,
optional schema flag (default: false
) that specifies whether the returned URL should be absolute or relative,
and optional BaseFileParams.
Returns a URL to download the file.
getInfo()
• Type
(id: string) => FileInfo | null
• Details
Expects a file ID.
Returns a FileInfo object or null
if the file does not exist.
getPublicUrl()
• Type
(id: string, schema?: boolean) => string | null
• Details
Expects a file ID
and optional schema flag (default: false
) that specifies whether the returned URL should be absolute or relative,
Returns the public URL of the file if available, or null
.
getThumbnailUrl()
• Type
(
id: string,
size?: number,
schema?: boolean,
params?: ThumbnailFileParams,
) => string
• Details
Expects a file ID,
optional size (default: 50
),
optional schema flag (default: false
),
and optional ThumbnailFileParams (default: {keepAspectRatio: false}
).
Returns the URL of the file thumbnail.
makePrivate()
• Type
(id: string) => boolean
• Details
Expects a file ID.
Sets the file to private and returns true
if successful, false
otherwise.
makePublic()
• Type
(id: string, params?: PublicFileParams) => boolean
• Details
Expects a file ID and optional PublicFileParams (default: {dir: ''}
).
Sets the file to public and returns true
if successful, false
otherwise.
saveAsBase64()
• Type
(id: string, basename: string) => FileInfo | null
• Details
Expects a file ID and a basename for the saved file.
Returns a FileInfo object or null
if the file could not be saved.
saveUploadedFile()
• Type
(file: UploadedFile) => FileInfo | null
• Details
Expects an UploadedFile object.
Returns a FileInfo object or null
if saving fails.