sobj

Types โ€‹

All shared types are exported from sobj/types.

๐Ÿ“ฅ Import โ€‹

ts
import type {
  SobjBody,
  SobjObject,
  SobjMetadata,
  SobjList,
  SobjRange,
  GetOptions,
  PutOptions,
  ListOptions,
  CopyOptions,
  PresignOptions,
  PresignPutOptions,
  MultipartUpload,
  MultipartPart,
  CreateMultipartOptions,
  ListVersionsOptions,
  SobjVersion,
  SobjVersions,
} from 'sobj/types'

๐Ÿชน SobjBody โ€‹

Accepted body types for uploads.

ts
type SobjBody =
  | string
  | Uint8Array
  | ArrayBuffer
  | Blob
  | ReadableStream<Uint8Array>

๐Ÿ“ฆ SobjObject โ€‹

Represents a downloaded object.

ts
interface SobjObject {
  readonly body: ReadableStream<Uint8Array>
  readonly metadata: SobjMetadata
}

๐Ÿ“ SobjMetadata โ€‹

Metadata associated with a stored object.

ts
interface SobjMetadata {
  readonly cacheControl?: string
  readonly contentDisposition?: string
  readonly contentEncoding?: string
  readonly contentLanguage?: string
  readonly contentType?: string
  readonly etag?: string
  readonly key: string
  readonly lastModified?: Date
  readonly metadata?: Readonly<Record<string, string>>
  readonly size?: number
}
PropertyTypeDescription
keystringObject key
sizenumberSize in bytes
etagstringETag / content hash
contentTypestringMIME type
lastModifiedDateLast-modified timestamp
metadataRecord<string, string>Custom user-defined metadata
cacheControlstringCache-Control header value
contentDispositionstringContent-Disposition header value
contentEncodingstringContent-Encoding header value
contentLanguagestringContent-Language header value

๐Ÿ“ SobjRange โ€‹

A byte range for partial downloads.

ts
interface SobjRange {
  readonly start?: number
  readonly end?: number
}

๐Ÿ“‹ SobjList โ€‹

Result of a list operation.

ts
interface SobjList {
  readonly cursor?: string
  readonly hasMore: boolean
  readonly objects: readonly SobjMetadata[]
  readonly prefixes: readonly string[]
}
PropertyTypeDescription
objectsSobjMetadata[]Objects in this page
prefixesstring[]Common prefixes (virtual directories) when using a delimiter
hasMorebooleanWhether more results are available
cursorstringCursor to pass to the next list call

โš™๏ธ GetOptions โ€‹

Options for get.

ts
interface GetOptions {
  readonly ifMatch?: string
  readonly ifModifiedSince?: Date
  readonly ifNoneMatch?: string
  readonly ifUnmodifiedSince?: Date
  readonly range?: SobjRange
}

โš™๏ธ PutOptions โ€‹

Options for put.

ts
interface PutOptions {
  readonly cacheControl?: string
  readonly contentDisposition?: string
  readonly contentEncoding?: string
  readonly contentLanguage?: string
  readonly contentType?: string
  readonly ifMatch?: string
  readonly ifNoneMatch?: string
  readonly metadata?: Readonly<Record<string, string>>
}

โš™๏ธ ListOptions โ€‹

Options for list.

ts
interface ListOptions {
  readonly cursor?: string
  readonly delimiter?: string
  readonly limit?: number
  readonly prefix?: string
}

โš™๏ธ CopyOptions โ€‹

Options for copy.

ts
interface CopyOptions {
  readonly cacheControl?: string
  readonly contentType?: string
  readonly metadata?: Readonly<Record<string, string>>
  readonly overwrite?: boolean
}

Set overwrite: false to fail if the destination already exists.


โš™๏ธ PresignOptions โ€‹

Options for presign.get.

ts
interface PresignOptions {
  readonly expiresIn?: number // seconds, default: 3600
}

โš™๏ธ PresignPutOptions โ€‹

Options for presign.put.

ts
interface PresignPutOptions extends PresignOptions {
  readonly contentLength?: number
  readonly contentType?: string
}

๐Ÿ“ฆ MultipartUpload โ€‹

Represents an in-progress multipart upload.

ts
interface MultipartUpload {
  readonly id: string
  readonly key: string
}

๐Ÿ“ฆ MultipartPart โ€‹

Represents a completed part of a multipart upload.

ts
interface MultipartPart {
  readonly etag: string
  readonly partNumber: number
}

๐Ÿ“ฆ CreateMultipartOptions โ€‹

Options for multipart.create. Extends PutOptions.

ts
interface CreateMultipartOptions extends PutOptions {}

๐Ÿท๏ธ SobjVersion โ€‹

Represents a specific version of an object.

ts
interface SobjVersion {
  readonly isDeleteMarker?: boolean
  readonly isLatest: boolean
  readonly metadata: SobjMetadata
  readonly version: string
}

๐Ÿท๏ธ SobjVersions โ€‹

Result of versioning.list.

ts
interface SobjVersions {
  readonly cursor?: string
  readonly hasMore: boolean
  readonly versions: readonly SobjVersion[]
}

โš™๏ธ ListVersionsOptions โ€‹

Options for versioning.list.

ts
interface ListVersionsOptions {
  readonly cursor?: string
  readonly limit?: number
}