Once a session is started, it is possible to upload encrypted files:

// assuming you have an <input> element of type "file" and the id "fileItem" on your page
const file = document.getElementById('fileItem').files[0];
const fileId = await fileKit.upload(file);


You can also upload ArrayBuffer, Buffer, Blob, and Uint8Array. For more information, read the documentation of upload().

After successfully encrypting and uploading a file, a unique identifier is returned: the file ID.

You have to store this identifier, as it is required for downloading:

await fileKit.downloadToDisk(fileId);

Instead of writing the file's content to the user's disk, you might want to get a File:

const file = await fileKit.download(fileId);

The encrypted files are currently only accessible to the user who uploaded them. If you want other users to download these files, you must explicitly share them.

This is covered in the next section.