Skip to main content
js

Files

Uploading and managing files.

Uploading Files

Uploading files to a Store in the most basic way:

const file = 'FILE_SELECTED_BY_USER'; // e.g. from a form (FormData.get('file'));

const fileId = await Endpoint.connection().store('STORE_ID').uploadFile({
file: file
});

const fileInfo = await Endpoint.connection().stores.getFileMetadata(fileId);

Modifying Files

 const currentFileMeta = await Endpoint.connection().stores.getFileMetadata('FILE_ID');

const deserializedFileMeta = deserializeObject(currentFileMeta.privateMeta);
const newFilePrivateMeta = {
...deserializedFileMeta,
name: 'New file meta'
};

await Endpoint.connection().stores.updateFileMetaData({
fileId: 'FILE_ID',
privateMeta: serializeObject(newFilePrivateMeta)
});