Skip to content

How to use PutObjectCommand

Jun Yuan edited this page May 19, 2024 · 4 revisions
import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3';
// Create an S3 client service object
const s3Client = new S3Client({
    region: process.env.BUCKET_REGION,
    credentials: {
        accessKeyId: process.env.ACCESS_KEY_ID,
        secretAccessKey: process.env.SECRET_ACCESS_KEY
    }
});

// Set the parameters
const params = {
    Bucket: //Bucket Name,
    Key: //Object Key,
    Body: //Object Value,   
};

const command = new PutObjectCommand(params);

await s3Client.send(command);

Clone this wiki locally