File storage
Use jet.storage(resourceName, storageName) to work with a configured storage resource. Paths and permissions are determined by that resource.
Upload a browser file
Pass the File selected by your application's file input:
import { Jet } from '@jet-admin/jet-sdk';
async function uploadDocument(jet: Jet, file: File) {
const response = await jet.storage('YOUR_RESOURCE', 'YOUR_STORAGE').uploadFile({
path: 'documents',
fileName: file.name,
file,
});
return response.result; // { path, url }
}uploadFile({ file, path?, fileName? }) accepts a Blob and uses multipart FormData. A browser File supplies its own multipart filename; fileName is also sent as a separate file_name field. The implementation references the global File constructor even for a Blob.
The resolved response has result.path, result.url, and state.uploadProgress / state.downloadProgress. These state values come from the completed server response. This method does not expose live progress callbacks.
Browse, create folders, and get URLs
import { Jet } from '@jet-admin/jet-sdk';
async function listDocuments(jet: Jet) {
const response = await jet.storage('YOUR_RESOURCE', 'YOUR_STORAGE')
.listObjects({ path: 'documents' });
return response.objects;
}
async function createFolder(jet: Jet, path: string) {
return jet.storage('YOUR_RESOURCE', 'YOUR_STORAGE').createFolder({ path });
}
async function getDownloadUrl(jet: Jet, path: string) {
const response = await jet.storage('YOUR_RESOURCE', 'YOUR_STORAGE').getObjectUrl({ path });
return response.url;
}
async function deleteFile(jet: Jet, path: string) {
return jet.storage('YOUR_RESOURCE', 'YOUR_STORAGE').deleteObject({ path });
}listObjects
Optional { path?: string }
{ objects, storageSize?, storageLimit? }
createFolder
{ path: string }
{ result: boolean }
getObjectUrl
{ path: string, expires?: number }
{ url: string }
deleteObject
{ path: string }
{ result: boolean }
Objects have path, url, type (file or folder), optional size, and dates converted to Date when returned by the listing API. Inspect result for create/delete operations.
expires is forwarded unchanged. Its unit, limits, and default are not specified in this SDK; use your storage API's contract before setting it. Listing has no SDK pagination argument. Folder deletion semantics are resource-specific.
Was this helpful?