No results for

Powered byAlgolia

S3Client.putObject(bucketName, objectKey, data)

S3Client.putObject uploads an object to a bucket.

ParameterTypeDescription
bucketNamestringName of the bucket to upload the object to.
objectKeystringName of the uploaded object.
datastring | ArrayBufferContent of the object to upload.

Example

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';
const testFile = open('./bonjour.txt', 'r');
export default function () {
// Let's upload our test file to the bucket
s3.putObject(testBucketName, testFileKey, testFile);
// And let's redownload it to verify it's correct
const obj = s3.getObject(testBucketName, testFileKey);
console.log(JSON.stringify(obj));
}