Skip to content

Upload Flow

Tusky uses a presigned URL flow for file uploads. This keeps file bytes off the API server and uploads directly to object storage.

  1. Request upload — Call the API to get a presigned URL and file ID.

  2. Upload bytes — PUT the file bytes directly to the presigned URL.

  3. Confirm — Tell the API the upload is complete. Status moves to hot.

The SDK wraps all three steps into a single call:

import { TuskyClient } from '@tuskydp/sdk';
import { readFile } from 'fs/promises';
const tusky = new TuskyClient({ apiKey: 'tdp_your_key' });
const data = await readFile('./report.pdf');
const file = await tusky.files.upload({
name: 'report.pdf',
mimeType: 'application/pdf',
vaultId: 'vault-uuid',
data,
});
console.log(file.status); // "hot"

If you’re not using the SDK, here’s each step in detail.

Terminal window
POST /api/files/upload
{
"name": "report.pdf",
"mimeType": "application/pdf",
"sizeBytes": 204800,
"vaultId": "vault-uuid"
}

Response:

{
"fileId": "file-uuid",
"uploadUrl": "https://spaces.example.com/...?X-Amz-Signature=..."
}

PUT the raw file bytes to the uploadUrl. Set the Content-Type header to match the MIME type:

Terminal window
curl -X PUT "https://spaces.example.com/...?X-Amz-Signature=..." \
-H "Content-Type: application/pdf" \
--data-binary @report.pdf
Terminal window
POST /api/files/{fileId}/confirm

The API verifies the file exists in storage and updates the status to hot. A background job is queued to sync the file to Walrus.

  1. File status is hot — available for immediate download from the hot cache
  2. The Walrus sync worker picks up the job and publishes to the Walrus network
  3. Status changes to synced once confirmed on Walrus
  4. Eventually, the hot eviction worker removes the hot cache copy (status → cold)

Track these transitions with webhooks or SDK polling.

For private vaults, the client must encrypt the file before uploading. See the encryption guide for details. The upload flow is the same — you just upload encrypted bytes and include the encryption metadata (wrappedKey, encryptionIv, plaintextSizeBytes, plaintextChecksumSha256) in the request.