S3Client allows interacting with AWS S3's buckets and objects. Namely, it allows the user to list buckets and the objects they contain, as well as download, uploading, and deleting objects. The S3Client operations are blocking, and we recommend reserving their usage to the setup and teardown functions as much as possible.
S3Client is included in both the dedicated jslib s3.js bundle, and the aws.js one, containing all the services clients.
Methods
Function | Description |
---|---|
listBuckets() | List the buckets the authenticated user has access to |
listObjects(bucketName, [prefix]) | List the objects contained in a bucket |
getObject(bucketName, objectKey) | Download an object from a bucket |
putObject(bucketName, objectKey, data) | Upload an object to a bucket |
deleteObject(bucketName, objectKey) | Delete an object from a bucket |
Throws
S3 Client methods will throw errors in case of failure.
Error | Condition |
---|---|
InvalidSignatureError | when invalid credentials were provided. |
S3ServiceError | when AWS replied to the requested operation with an error. |