No results for

Powered byAlgolia

S3Client.putObject(bucketName, objectKey, data)

S3Client.putObject uploads an object to a bucket.


bucketNamestringName of the bucket to upload the object to.
objectKeystringName of the uploaded object.
datastring | ArrayBufferContent of the object to upload.
paramsPutObjectParams (optional)Options for the request.


contentDispositionstring (optional)Specifies presentational information for the object. For more information, see RFC 6266.
contentEncodingstring (optional)Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field. For more information, see RFC 2616.
contentLengthnumber (optional)Size of the body in bytes. This parameter is useful when the size of the body cannot be determined automatically.
contentMD5string (optional)The base64-encoded 128-bit MD5 digest of the message (without the headers) according to RFC 1864. This header can be used as a message integrity check to verify that the received message is identical to the message that was sent.
contentTypestring (optional)A standard MIME type describing the format of the object data. For more information, see RFC 2616.


Promise<void>A Promise that fulfills when the object has been uploaded to the S3 bucket.


import { AWSConfig, S3Client } from '';
const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
const s3 = new S3Client(awsConfig);
const testBucketName = 'test-jslib-aws';
const testFileKey = 'bonjour.txt';
const testFile = open('./bonjour.txt', 'r');
export default async function () {
// Let's upload our test file to the bucket
await s3.putObject(testBucketName, testFileKey, testFile, {
contentType: 'text/plain',
contentLength: testFile.length,
// And let's redownload it to verify it's correct
const obj = await s3.getObject(testBucketName, testFileKey);