aws-将字符串作为文件上传到S3存储桶 [英] aws - Uploading a string as file to a S3 bucket
本文介绍了aws-将字符串作为文件上传到S3存储桶的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用适用于NodeJS的AWS开发工具包将字符串作为文件保存到AWS S3存储桶.PUT请求成功,但未在S3存储桶中创建文件.以下是我的代码段.
I'm trying to save a string as a file to an AWS S3 bucket using the AWS SDK for NodeJS. The PUT request gets succeeded, but the file does not get created in the S3 bucket. Following is a snippet from my code.
const s3 = new S3({ apiVersion: '2006-03-01' });
const JS_code = `
let x = 'Hello World';
`;
// I'm using the following method inside an async function.
await s3.putObject({
Bucket: 'my-bucket-gayashan',
Key: 'myFile.js',
ContentType:'binary',
Body: Buffer.from(JS_code, 'binary')
});
有人可以帮我吗?
推荐答案
您应使用 查看全文