getFile
Get a file from OneEntry cloud storage.
Description
Fetches a stored file and resolves to the raw Response of the file request. A missing file also resolves to a Response (with status 404), so check response.ok before reading the body.
.getFile(
,
,
,
,
);
Parameters schema
Schema
id(required): number
ID of the object the file belongs to; sets the folder name in the storage.
example: 3787
type(required): string
Storage type; determines the folder the file is stored in, for example "page".
example: "page"
entity(required): string
Name of the entity the file belongs to; sets the folder name in the storage.
example: "editor"
filename(required): string
File name.
example: "file.png"
template: string
Preview template: its numeric ID or its marker, for example "preview". Without it, no preview is generated.
example: "preview_template"
Examples
Minimal example
const response = await FileUploading.getFile(123, 'page', 'editor', 'file.png');
Example response
The method resolves to a Fetch API Response, not to JSON. Read the file from it:
const response = await FileUploading.getFile(123, 'page', 'editor', 'file.png');
if (response instanceof Response && response.ok) {
const blob = await response.blob();
}