Stratal API Reference
    Preparing search index...

    Class StorageService

    Storage Service

    Main facade for storage operations. Request-scoped for proper isolation.

    @inject(STORAGE_TOKENS.StorageService)
    private readonly storage: StorageService

    await this.storage.upload(file, 'documents/report.pdf')

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    options: StorageConfig
    storageManager: StorageManagerService

    Methods

    • Build full path with disk root and path template substitution

      Parameters

      • relativePath: string

        Relative path within the disk

      • diskName: string

        Name of the disk

      Returns string

      Full path including disk root

    • Chunked upload for streaming data without known size Uses multipart upload under the hood - handles retries and large files

      Use this method when:

      • Content-Length is unknown or unreliable
      • Uploading from streams that can't be rewound
      • Need automatic retry handling for transient failures

      Parameters

      • body: StreamingBlobPayloadInputTypes | undefined

        Content to upload (stream or buffer)

      • relativePath: string

        Relative path within the disk

      • options: Omit<UploadOptions, "size"> & { size?: number }

        Upload options (mimeType required, size optional)

      • Optionaldisk: string

        Optional disk name (uses default if not provided)

      Returns Promise<
          {
              disk: string;
              fullPath: string;
              mimeType: string;
              path: string;
              size: number;
              uploadedAt: Date;
          },
      >

      Upload result with metadata

    • Delete a file from storage

      Parameters

      • relativePath: string

        Relative path within the disk

      • Optionaldisk: string

        Optional disk name (uses default if not provided)

      Returns Promise<void>

    • Check if a file exists in storage

      Parameters

      • relativePath: string

        Relative path within the disk

      • Optionaldisk: string

        Optional disk name (uses default if not provided)

      Returns Promise<boolean>

      True if file exists, false otherwise

    • Generate a presigned delete URL

      Parameters

      • relativePath: string

        Relative path within the disk

      • OptionalexpiresIn: number

        Optional expiry time in seconds (uses default if not provided)

      • Optionaldisk: string

        Optional disk name (uses default if not provided)

      Returns Promise<
          {
              expiresAt: Date;
              expiresIn: number;
              method: "GET"
              | "PUT"
              | "DELETE"
              | "HEAD";
              url: string;
          },
      >

      Presigned URL result

    • Generate a presigned download URL

      Parameters

      • relativePath: string

        Relative path within the disk

      • OptionalexpiresIn: number

        Optional expiry time in seconds (uses default if not provided)

      • Optionaldisk: string

        Optional disk name (uses default if not provided)

      Returns Promise<
          {
              expiresAt: Date;
              expiresIn: number;
              method: "GET"
              | "PUT"
              | "DELETE"
              | "HEAD";
              url: string;
          },
      >

      Presigned URL result

    • Generate a presigned upload URL

      Parameters

      • relativePath: string

        Relative path within the disk

      • OptionalexpiresIn: number

        Optional expiry time in seconds (uses default if not provided)

      • Optionaldisk: string

        Optional disk name (uses default if not provided)

      Returns Promise<
          {
              expiresAt: Date;
              expiresIn: number;
              method: "GET"
              | "PUT"
              | "DELETE"
              | "HEAD";
              url: string;
          },
      >

      Presigned URL result

    • Generate a presigned URL for any method

      Parameters

      • relativePath: string

        Relative path within the disk

      • method: "GET" | "PUT" | "DELETE" | "HEAD"

        HTTP method (GET, PUT, DELETE, HEAD)

      • OptionalexpiresIn: number

        Optional expiry time in seconds (uses default if not provided)

      • Optionaldisk: string

        Optional disk name (uses default if not provided)

      Returns Promise<
          {
              expiresAt: Date;
              expiresIn: number;
              method: "GET"
              | "PUT"
              | "DELETE"
              | "HEAD";
              url: string;
          },
      >

      Presigned URL result

    • Substitute template variables in path Override this method in subclasses to add custom substitutions

      Parameters

      • path: string

        Path with template variables

      Returns string

      Path with substituted variables

    • Upload content to storage

      Parameters

      • body: StreamingBlobPayloadInputTypes | undefined

        Content to upload (stream, buffer, or string)

      • relativePath: string

        Relative path within the disk

      • options: UploadOptions

        Upload options including size and mime type

      • Optionaldisk: string

        Optional disk name (uses default if not provided)

      Returns Promise<
          {
              disk: string;
              fullPath: string;
              mimeType: string;
              path: string;
              size: number;
              uploadedAt: Date;
          },
      >

      Upload result with metadata