Skip to main content

spaces

Workspace API


Workspace API / services/storage/spaces

services/storage/spaces

Classes

StorageClient

Defined in: services/storage/spaces.ts:67

Constructors

Constructor

new StorageClient(bucketName): StorageClient

Defined in: services/storage/spaces.ts:71

Parameters
bucketName

string

Returns

StorageClient

Methods

downloadFile()

downloadFile(storagePath): Promise<Buffer<ArrayBufferLike>>

Defined in: services/storage/spaces.ts:92

Download a file from Spaces

Parameters
storagePath

string

Returns

Promise<Buffer<ArrayBufferLike>>

getFileStream()

getFileStream(storagePath): Promise<{ Body: any; ContentType?: string; ContentLength?: number; LastModified?: Date; }>

Defined in: services/storage/spaces.ts:131

Get file stream from Spaces (for streaming to client) Returns the response object with Body stream and metadata

Parameters
storagePath

string

Returns

Promise<{ Body: any; ContentType?: string; ContentLength?: number; LastModified?: Date; }>

downloadToFile()

downloadToFile(storagePath, filePath): Promise<void>

Defined in: services/storage/spaces.ts:170

Download a file from Spaces to a file path

Parameters
storagePath

string

filePath

string

Returns

Promise<void>

uploadFile()

uploadFile(storagePath, content, contentType?): Promise<void>

Defined in: services/storage/spaces.ts:180

Upload a file to Spaces

Parameters
storagePath

string

content

string | Buffer<ArrayBufferLike>

contentType?

string

Returns

Promise<void>

deleteFile()

deleteFile(storagePath): Promise<void>

Defined in: services/storage/spaces.ts:203

Delete a file from Spaces

Parameters
storagePath

string

Returns

Promise<void>

fileExists()

fileExists(storagePath): Promise<boolean>

Defined in: services/storage/spaces.ts:227

Check if a file exists

Parameters
storagePath

string

Returns

Promise<boolean>

getFileMetadata()

getFileMetadata(storagePath): Promise<any>

Defined in: services/storage/spaces.ts:249

Get file metadata

Parameters
storagePath

string

Returns

Promise<any>

listFiles()

listFiles(options): Promise<[any[], any]>

Defined in: services/storage/spaces.ts:278

List files with options

Parameters
options
prefix?

string

delimiter?

string

maxResults?

number

versions?

boolean

continuationToken?

string

Returns

Promise<[any[], any]>

generateSignedUrl()

generateSignedUrl(filePath, options): Promise<string>

Defined in: services/storage/spaces.ts:332

Generate signed URL for temporary access

Parameters
filePath

string

options
action

"read" | "write" | "delete"

expires

string | number | Date

contentType?

string

version?

string

responseDisposition?

string

Returns

Promise<string>

uploadFileWithMetadata()

uploadFileWithMetadata(filePath, content, options): Promise<void>

Defined in: services/storage/spaces.ts:393

Upload file with custom metadata

Parameters
filePath

string

content

string | Buffer<ArrayBufferLike>

options
contentType?

string

metadata?

Record<string, string>

Returns

Promise<void>

bucketExists()

bucketExists(): Promise<boolean>

Defined in: services/storage/spaces.ts:430

Check if bucket exists

Returns

Promise<boolean>

copyFile()

copyFile(sourcePath, destinationPath): Promise<void>

Defined in: services/storage/spaces.ts:453

Copy a file to a new location (without deleting the original)

Parameters
sourcePath

string

destinationPath

string

Returns

Promise<void>

moveFile()

moveFile(sourcePath, destinationPath): Promise<void>

Defined in: services/storage/spaces.ts:482

Move a file to a new location (copy + delete)

Parameters
sourcePath

string

destinationPath

string

Returns

Promise<void>

Functions

getS3Client()

getS3Client(): S3Client

Defined in: services/storage/spaces.ts:32

Get S3 client instance (singleton) for DigitalOcean Spaces

Returns

S3Client