ObjectStackObjectStack

Storage

Storage protocol schemas

Storage Service Protocol

Defines the API contract for client-side file operations. Focuses on secure, direct-to-cloud uploads (Presigned URLs) rather than proxying bytes through the API server.

Source: packages/spec/src/api/storage.zod.ts

TypeScript Usage

import { CompleteChunkedUploadRequestSchema, CompleteChunkedUploadResponseSchema, CompleteUploadRequestSchema, FileDownloadUrlResponseSchema, FileTypeValidationSchema, FileUploadResponseSchema, GetPresignedUrlRequestSchema, InitiateChunkedUploadRequestSchema, InitiateChunkedUploadResponseSchema, PresignedUrlResponseSchema, RawUploadResponseSchema, UploadChunkRequestSchema, UploadChunkResponseSchema, UploadProgressSchema } from '@objectstack/spec/api';
import type { CompleteChunkedUploadRequest, CompleteChunkedUploadResponse, CompleteUploadRequest, FileDownloadUrlResponse, FileTypeValidation, FileUploadResponse, GetPresignedUrlRequest, InitiateChunkedUploadRequest, InitiateChunkedUploadResponse, PresignedUrlResponse, RawUploadResponse, UploadChunkRequest, UploadChunkResponse, UploadProgress } from '@objectstack/spec/api';

// Validate data
const result = CompleteChunkedUploadRequestSchema.parse(data);

CompleteChunkedUploadRequest

Properties

PropertyTypeRequiredDescription
uploadIdstringMultipart upload session ID
parts{ chunkIndex: integer; eTag: string }[]Ordered list of uploaded parts for assembly

Nested Shape: CompleteChunkedUploadRequest.parts[number]

PropertyTypeRequiredDescription
chunkIndexintegerChunk index
eTagstringETag returned from chunk upload

CompleteChunkedUploadResponse

Properties

PropertyTypeRequiredDescription
successbooleanOperation success status
error{ code: Enum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | …>; declaredCode?: string; message: string; userMessage?: string; … }optionalError details if success is false
meta{ timestamp: string; duration?: number; requestId?: string; traceId?: string }optionalResponse metadata
data{ fileId: string; key: string; size: integer; mimeType: string; … }

Nested Shape: CompleteChunkedUploadResponse.error

PropertyTypeRequiredDescription
codeEnum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | …>Error code (e.g. VALIDATION_ERROR; StandardErrorCode ∪ the ledger the serving side registers — ERROR_CODE_LEDGER for framework packages)
declaredCodestringoptionalThe producer-declared code, verbatim, when it is not a member of the closed code vocabulary — the open, author-authored channel (app-specific spellings; ADR-0112)
messagestringReadable error message
userMessagestringoptionalProducer-marked user-facing refusal text, verbatim. Present exactly when the producer opted in at throw time; consumers render it to end users and keep their generic substitution for anything unmarked. Status-agnostic; never replaces message.
categorystringoptionalError category (e.g. validation, authorization)
httpStatusintegeroptionalHTTP status of the response carrying this error
detailsanyoptionalAdditional error context (e.g. field validation errors)
requestIdstringoptionalRequest ID for tracking

Nested Shape: CompleteChunkedUploadResponse.data

PropertyTypeRequiredDescription
fileIdstringFinal file ID
keystringStorage key/path of the assembled file
sizeintegerTotal file size in bytes
mimeTypestringFile MIME type
eTagstringoptionalFinal ETag of the assembled file
urlstringoptionalDownload URL for the assembled file

CompleteUploadRequest

Properties

PropertyTypeRequiredDescription
fileIdstringFile ID returned from presigned request
eTagstringoptionalS3 ETag verification

FileDownloadUrlResponse

Properties

PropertyTypeRequiredDescription
successbooleanOperation success status
error{ code: Enum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | …>; declaredCode?: string; message: string; userMessage?: string; … }optionalError details if success is false
meta{ timestamp: string; duration?: number; requestId?: string; traceId?: string }optionalResponse metadata
data{ url: string }

Nested Shape: FileDownloadUrlResponse.error

PropertyTypeRequiredDescription
codeEnum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | …>Error code (e.g. VALIDATION_ERROR; StandardErrorCode ∪ the ledger the serving side registers — ERROR_CODE_LEDGER for framework packages)
declaredCodestringoptionalThe producer-declared code, verbatim, when it is not a member of the closed code vocabulary — the open, author-authored channel (app-specific spellings; ADR-0112)
messagestringReadable error message
userMessagestringoptionalProducer-marked user-facing refusal text, verbatim. Present exactly when the producer opted in at throw time; consumers render it to end users and keep their generic substitution for anything unmarked. Status-agnostic; never replaces message.
categorystringoptionalError category (e.g. validation, authorization)
httpStatusintegeroptionalHTTP status of the response carrying this error
detailsanyoptionalAdditional error context (e.g. field validation errors)
requestIdstringoptionalRequest ID for tracking

Nested Shape: FileDownloadUrlResponse.data

PropertyTypeRequiredDescription
urlstringShort-lived signed download URL; may be server-relative

FileTypeValidation

Properties

PropertyTypeRequiredDescription
modeEnum<'whitelist' | 'blacklist'>whitelist = only allow listed types, blacklist = block listed types
mimeTypesstring[]List of MIME types to allow or block (e.g., "image/jpeg", "application/pdf")
extensionsstring[]optionalList of file extensions to allow or block (e.g., ".jpg", ".pdf")
maxFileSizeintegeroptionalMaximum file size in bytes
minFileSizeintegeroptionalMinimum file size in bytes (e.g., reject empty files)

FileUploadResponse

Properties

PropertyTypeRequiredDescription
successbooleanOperation success status
error{ code: Enum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | …>; declaredCode?: string; message: string; userMessage?: string; … }optionalError details if success is false
meta{ timestamp: string; duration?: number; requestId?: string; traceId?: string }optionalResponse metadata
data{ path: string; name: string; size: integer; mimeType: string; … }Uploaded file metadata

Nested Shape: FileUploadResponse.error

PropertyTypeRequiredDescription
codeEnum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | …>Error code (e.g. VALIDATION_ERROR; StandardErrorCode ∪ the ledger the serving side registers — ERROR_CODE_LEDGER for framework packages)
declaredCodestringoptionalThe producer-declared code, verbatim, when it is not a member of the closed code vocabulary — the open, author-authored channel (app-specific spellings; ADR-0112)
messagestringReadable error message
userMessagestringoptionalProducer-marked user-facing refusal text, verbatim. Present exactly when the producer opted in at throw time; consumers render it to end users and keep their generic substitution for anything unmarked. Status-agnostic; never replaces message.
categorystringoptionalError category (e.g. validation, authorization)
httpStatusintegeroptionalHTTP status of the response carrying this error
detailsanyoptionalAdditional error context (e.g. field validation errors)
requestIdstringoptionalRequest ID for tracking

Nested Shape: FileUploadResponse.data

PropertyTypeRequiredDescription
pathstringFile path
namestringFile name
sizeintegerFile size in bytes
mimeTypestringMIME type
lastModifiedstringLast modified timestamp
createdstringCreation timestamp
etagstringoptionalEntity tag
fileIdstringoptionalOpaque sys_file id (ADR-0104 D3 file-as-reference)

GetPresignedUrlRequest

Properties

PropertyTypeRequiredDescription
filenamestringOriginal filename
mimeTypestringFile MIME type
sizenumberFile size in bytes
scopestringoptional (default: "user")Target storage scope (e.g. user, private, public)
bucketstringoptionalSpecific bucket override (admin only)

InitiateChunkedUploadRequest

Properties

PropertyTypeRequiredDescription
filenamestringOriginal filename
mimeTypestringFile MIME type
totalSizeintegerTotal file size in bytes
chunkSizeintegeroptional (default: 5242880)Size of each chunk in bytes (minimum 5MB per S3 spec)
scopestringoptional (default: "user")Target storage scope
bucketstringoptionalSpecific bucket override (admin only)
metadataRecord<string, string>optionalCustom metadata key-value pairs

InitiateChunkedUploadResponse

Properties

PropertyTypeRequiredDescription
successbooleanOperation success status
error{ code: Enum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | …>; declaredCode?: string; message: string; userMessage?: string; … }optionalError details if success is false
meta{ timestamp: string; duration?: number; requestId?: string; traceId?: string }optionalResponse metadata
data{ uploadId: string; resumeToken: string; fileId: string; totalChunks: integer; … }

Nested Shape: InitiateChunkedUploadResponse.error

PropertyTypeRequiredDescription
codeEnum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | …>Error code (e.g. VALIDATION_ERROR; StandardErrorCode ∪ the ledger the serving side registers — ERROR_CODE_LEDGER for framework packages)
declaredCodestringoptionalThe producer-declared code, verbatim, when it is not a member of the closed code vocabulary — the open, author-authored channel (app-specific spellings; ADR-0112)
messagestringReadable error message
userMessagestringoptionalProducer-marked user-facing refusal text, verbatim. Present exactly when the producer opted in at throw time; consumers render it to end users and keep their generic substitution for anything unmarked. Status-agnostic; never replaces message.
categorystringoptionalError category (e.g. validation, authorization)
httpStatusintegeroptionalHTTP status of the response carrying this error
detailsanyoptionalAdditional error context (e.g. field validation errors)
requestIdstringoptionalRequest ID for tracking

Nested Shape: InitiateChunkedUploadResponse.data

PropertyTypeRequiredDescription
uploadIdstringMultipart upload session ID
resumeTokenstringOpaque token for resuming interrupted uploads
fileIdstringAssigned file ID
totalChunksintegerExpected number of chunks
chunkSizeintegerChunk size in bytes
expiresAtstringUpload session expiration timestamp

PresignedUrlResponse

Properties

PropertyTypeRequiredDescription
successbooleanOperation success status
error{ code: Enum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | …>; declaredCode?: string; message: string; userMessage?: string; … }optionalError details if success is false
meta{ timestamp: string; duration?: number; requestId?: string; traceId?: string }optionalResponse metadata
data{ uploadUrl: string; downloadUrl?: string; fileId: string; method: Enum<'PUT' | 'POST'>; … }

Nested Shape: PresignedUrlResponse.error

PropertyTypeRequiredDescription
codeEnum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | …>Error code (e.g. VALIDATION_ERROR; StandardErrorCode ∪ the ledger the serving side registers — ERROR_CODE_LEDGER for framework packages)
declaredCodestringoptionalThe producer-declared code, verbatim, when it is not a member of the closed code vocabulary — the open, author-authored channel (app-specific spellings; ADR-0112)
messagestringReadable error message
userMessagestringoptionalProducer-marked user-facing refusal text, verbatim. Present exactly when the producer opted in at throw time; consumers render it to end users and keep their generic substitution for anything unmarked. Status-agnostic; never replaces message.
categorystringoptionalError category (e.g. validation, authorization)
httpStatusintegeroptionalHTTP status of the response carrying this error
detailsanyoptionalAdditional error context (e.g. field validation errors)
requestIdstringoptionalRequest ID for tracking

Nested Shape: PresignedUrlResponse.data

PropertyTypeRequiredDescription
uploadUrlstringPUT/POST URL for direct upload
downloadUrlstringoptionalPublic/Private preview URL
fileIdstringTemporary File ID
methodEnum<'PUT' | 'POST'>HTTP Method to use
headersRecord<string, string>optionalRequired headers for upload
expiresInnumberURL expiry in seconds

RawUploadResponse

Properties

PropertyTypeRequiredDescription
successbooleanOperation success status
error{ code: Enum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | …>; declaredCode?: string; message: string; userMessage?: string; … }optionalError details if success is false
meta{ timestamp: string; duration?: number; requestId?: string; traceId?: string }optionalResponse metadata
data{ key: string }

Nested Shape: RawUploadResponse.error

PropertyTypeRequiredDescription
codeEnum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | …>Error code (e.g. VALIDATION_ERROR; StandardErrorCode ∪ the ledger the serving side registers — ERROR_CODE_LEDGER for framework packages)
declaredCodestringoptionalThe producer-declared code, verbatim, when it is not a member of the closed code vocabulary — the open, author-authored channel (app-specific spellings; ADR-0112)
messagestringReadable error message
userMessagestringoptionalProducer-marked user-facing refusal text, verbatim. Present exactly when the producer opted in at throw time; consumers render it to end users and keep their generic substitution for anything unmarked. Status-agnostic; never replaces message.
categorystringoptionalError category (e.g. validation, authorization)
httpStatusintegeroptionalHTTP status of the response carrying this error
detailsanyoptionalAdditional error context (e.g. field validation errors)
requestIdstringoptionalRequest ID for tracking

Nested Shape: RawUploadResponse.data

PropertyTypeRequiredDescription
keystringStorage key the bytes were written to

UploadChunkRequest

Properties

PropertyTypeRequiredDescription
uploadIdstringMultipart upload session ID
chunkIndexintegerZero-based chunk index
resumeTokenstringResume token from initiate response

UploadChunkResponse

Properties

PropertyTypeRequiredDescription
successbooleanOperation success status
error{ code: Enum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | …>; declaredCode?: string; message: string; userMessage?: string; … }optionalError details if success is false
meta{ timestamp: string; duration?: number; requestId?: string; traceId?: string }optionalResponse metadata
data{ chunkIndex: integer; eTag: string; bytesReceived: integer }

Nested Shape: UploadChunkResponse.error

PropertyTypeRequiredDescription
codeEnum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | …>Error code (e.g. VALIDATION_ERROR; StandardErrorCode ∪ the ledger the serving side registers — ERROR_CODE_LEDGER for framework packages)
declaredCodestringoptionalThe producer-declared code, verbatim, when it is not a member of the closed code vocabulary — the open, author-authored channel (app-specific spellings; ADR-0112)
messagestringReadable error message
userMessagestringoptionalProducer-marked user-facing refusal text, verbatim. Present exactly when the producer opted in at throw time; consumers render it to end users and keep their generic substitution for anything unmarked. Status-agnostic; never replaces message.
categorystringoptionalError category (e.g. validation, authorization)
httpStatusintegeroptionalHTTP status of the response carrying this error
detailsanyoptionalAdditional error context (e.g. field validation errors)
requestIdstringoptionalRequest ID for tracking

Nested Shape: UploadChunkResponse.data

PropertyTypeRequiredDescription
chunkIndexintegerChunk index that was uploaded
eTagstringChunk ETag for multipart completion
bytesReceivedintegerBytes received for this chunk

UploadProgress

Properties

PropertyTypeRequiredDescription
successbooleanOperation success status
error{ code: Enum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | …>; declaredCode?: string; message: string; userMessage?: string; … }optionalError details if success is false
meta{ timestamp: string; duration?: number; requestId?: string; traceId?: string }optionalResponse metadata
data{ uploadId: string; fileId: string; filename: string; totalSize: integer; … }

Nested Shape: UploadProgress.error

PropertyTypeRequiredDescription
codeEnum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | …>Error code (e.g. VALIDATION_ERROR; StandardErrorCode ∪ the ledger the serving side registers — ERROR_CODE_LEDGER for framework packages)
declaredCodestringoptionalThe producer-declared code, verbatim, when it is not a member of the closed code vocabulary — the open, author-authored channel (app-specific spellings; ADR-0112)
messagestringReadable error message
userMessagestringoptionalProducer-marked user-facing refusal text, verbatim. Present exactly when the producer opted in at throw time; consumers render it to end users and keep their generic substitution for anything unmarked. Status-agnostic; never replaces message.
categorystringoptionalError category (e.g. validation, authorization)
httpStatusintegeroptionalHTTP status of the response carrying this error
detailsanyoptionalAdditional error context (e.g. field validation errors)
requestIdstringoptionalRequest ID for tracking

Nested Shape: UploadProgress.data

PropertyTypeRequiredDescription
uploadIdstringMultipart upload session ID
fileIdstringAssigned file ID
filenamestringOriginal filename
totalSizeintegerTotal file size in bytes
uploadedSizeintegerBytes uploaded so far
totalChunksintegerTotal expected chunks
uploadedChunksintegerNumber of chunks uploaded
percentCompletenumberUpload progress percentage
statusEnum<'in_progress' | 'completing' | 'completed' | 'failed' | 'expired'>Current upload session status
startedAtstringUpload session start timestamp
expiresAtstringSession expiration timestamp

On this page