No results for

Powered byAlgolia

S3Client.deleteObject(bucketName, objectKey)

S3Client.deleteObject deletes an object from a bucket.

ParameterTypeDescription
bucketNamestringName of the bucket to delete the object from.
objectKeystringName of the object to delete.

Example

import exec from 'k6/execution';
import { AWSConfig, S3Client } from 'https://jslib.k6.io/aws/0.4.0/s3.js';
const awsConfig = new AWSConfig(
__ENV.AWS_REGION,
__ENV.AWS_ACCESS_KEY_ID,
__ENV.AWS_SECRET_ACCESS_KEY
);
const s3 = new S3Client(awsConfig);
const testBucketName = 'test-jslib-aws';
const testFileKey = 'bonjour.txt';
export default function () {
// Let's delete our test object
s3.deleteObject(testBucketName, testFileKey);
// And make sure it was indeed deleted
const objects = s3.listObjects();
if (objects.filter((o) => o.name === testBucketName).length != 0) {
exec.test.abort();
}
}