Skip to content

Instantly share code, notes, and snippets.

@studiotomi
Created January 11, 2023 16:38
Show Gist options
  • Save studiotomi/a8ed6c84764d787c417e11b772576934 to your computer and use it in GitHub Desktop.
Save studiotomi/a8ed6c84764d787c417e11b772576934 to your computer and use it in GitHub Desktop.
String to bucket in javascript
const putS3StringObject = async (bucket, key, str) => {
try {
const s3 = new aws_sdk_1.S3();
const buf = Buffer.from(str);
await s3.putObject({
Key: key,
Bucket: bucket,
Body: buf,
ContentEncoding: 'base64'
}).promise();
} catch (err) {
throw new Error(`Error putting object: ${err.message}`);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment