Created
January 11, 2023 16:38
-
-
Save studiotomi/a8ed6c84764d787c417e11b772576934 to your computer and use it in GitHub Desktop.
String to bucket in javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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