✦Spectra SDK Docs

Agent doc: Storage JS SDK

Package

Purpose

Storage JS SDK performs app-user scoped file/object operations against Storage Platform.

API tree

Storage JS SDK
├─ setup
│  ├─ new SpectraStorageClient(config)
│  └─ createSpectraStorageClient(config)
└─ files
   ├─ listFiles(options?)
   ├─ uploadFile(input)
   ├─ uploadImage(input)
   ├─ uploadFile(fileOrBlob, options)   # legacy compatible
   ├─ uploadImage(file, options?)       # legacy compatible
   ├─ getDownloadUrl(path)
   ├─ downloadBlob(path)
   └─ deleteFile(path)

Public setup inputs

Required auth object and token boundary

Agent integration order

1. Verify Auth SDK login/session/token first.

2. Create SpectraStorageClient with projectId and auth.

3. If upload fails before Storage API response, verify auth.getSession() and a single auth.getAccessToken({ service: "storage" }) call. Do not put forceRefresh: true in an upload loop unless Platform CS explicitly asks for a one-off diagnostic.

4. Implement uploadFile({ file, path, context?, fileInfo?, metadata? }) for generic files or videos.

5. Implement uploadImage({ file, path? | directory?, context?, fileInfo?, metadata? }) where the UI accepts only image blobs.

6. Persist the returned object reference in Chat/community/review domain records instead of copying binary data into those systems.

7. Implement listFiles().

8. Implement getDownloadUrl() or downloadBlob() depending on the UI need.

9. Implement deleteFile() for user-owned objects only.

Public operations

Consumer example

import { SpectraStorageClient } from "@spectra-platform/storage-sdk";

const storage = new SpectraStorageClient({
  projectId,
  auth,
});

const object = await storage.uploadFile({
  file,
  path: "/reviews/photo.jpg",
  visibility: "private",
  context: "review",
  fileInfo: {
    originalName: file.name,
    fingerprint: `${file.name}|${file.size}|${file.type}|${file.lastModified}`,
    lastModified: file.lastModified,
  },
});

const listed = await storage.listFiles({ prefix: "/reviews/" });
const url = await storage.getDownloadUrl(object.objectKey);

Current caveats

Unsupported or separate gates

Escalate to Platform CS when