Appearance
上传对象
js
const mime = require("mime-types");
const { PutObjectCommand } = require("@aws-sdk/client-s3");
const client = require("./client");
const putObject = (filepath, Bucket, Body, Key) => {
return new Promise(async (resolve, reject) => {
try {
const input = {
Body,
Bucket,
Key,
ContentType: mime.lookup(filepath),
};
const command = new PutObjectCommand(input);
await client.send(command);
resolve();
} catch (error) {
reject(error);
}
});
};
module.exports = putObject;