Skip to main content
The S3ResourceClient allows you to perform operations on S3 buckets, such as listing objects, uploading files, and generating presigned URLs.

Usage

import { myS3Client } from "./clients";

// List objects in a bucket
const listResult = await myS3Client.invoke(
  "ListObjectsV2",
  { Bucket: "my-bucket", Prefix: "uploads/" },
  "list-files"
);

if (listResult.ok) {
  console.log(listResult.result.data);
}

// Generate a presigned URL for uploading a file
const urlResult = await myS3Client.invoke(
  "GeneratePresignedUrl",
  { Bucket: "my-bucket", Key: "new-file.jpg", expiresIn: 3600 },
  "get-upload-url"
);

if (urlResult.ok && "presignedUrl" in urlResult.result) {
  console.log("Upload URL:", urlResult.result.presignedUrl);
}

Inputs

The invoke method accepts the following arguments:
command
string
required
The S3 command to execute. Supported commands include "ListObjectsV2", "HeadObject", "GetObjectTagging", "PutObjectTagging", "DeleteObject", "DeleteObjects", "CopyObject", "ListBuckets", "GetBucketLocation", "GeneratePresignedUrl".
params
Record<string, unknown>
required
The parameters for the command, matching the AWS SDK input shape (e.g., {(Bucket, Key, Prefix)}).
invocationKey
string
required
A unique identifier for this operation.
options
object
Optional configuration object.

Outputs

On success (ok: true), the result object structure depends on the command.

Standard Commands

For most commands (e.g., ListObjectsV2, HeadObject):
kind
"storage"
Discriminator for the response type.
command
string
The command that was executed.
data
unknown
The result data from S3.

GeneratePresignedUrl

For the GeneratePresignedUrl command:
kind
"storage"
Discriminator for the response type.
presignedUrl
string
The generated presigned URL.
expiresAt
string
The expiration timestamp of the URL.