No results for

Powered byAlgolia

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.


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


S3 Client methods will throw errors in case of failure.

InvalidSignatureErrorwhen invalid credentials were provided.
S3ServiceErrorwhen AWS replied to the requested operation with an error.


import { check } from 'k6';
import exec from 'k6/execution';
import http from 'k6/http';
import { AWSConfig, S3Client } from '';
const awsConfig = new AWSConfig(
const s3 = new S3Client(awsConfig);
const testBucketName = 'test-jslib-aws';
const testInputFileKey = 'productIDs.json';
const testOutputFileKey = `results-${}.json`;
export function setup() {
// If our test bucket does not exist, abort the execution.
const buckets = s3.listBuckets();
if (buckets.filter((b) => === testBucketName).length == 0) {
// If our test object does not exist, abort the execution.
const objects = s3.listObjects(testBucketName);
if (objects.filter((o) => o.key === testInputFileKey).length == 0) {
// Download the S3 object containing our test data
const inputObject = s3.getObject(testBucketName, testInputFileKey);
// Let's return the downloaded S3 object's data from the
// setup function to allow the default function to use it.
return {
productIDs: JSON.parse(,
export default function (data) {
// Pick a random product ID from our test data
const randomProductID = data.productIDs[Math.floor(Math.random() * data.productIDs.length)];
// Query our ecommerce website's product page using the ID
const res = http.get(`${randomProductID}/`);
check(res, { 'is status 200': res.status === 200 });
export function handleSummary(data) {
// Once the load test is over, let's upload the results to our
// S3 bucket. This is executed after teardown.
s3.putObject(testBucketName, testOutputFileKey, JSON.stringify(data));