s3-simp/s3simp.js
2025-03-10 16:45:39 +08:00

25 lines
440 B
JavaScript

import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3";
export function createClient(region, maxAttempts) {
return new S3Client({ region, maxAttempts });
}
export async function upload({
client,
Bucket,
Key,
Body,
ContentMD5,
ContentType,
...rest
}) {
const command = new PutObjectCommand({
Bucket,
Key,
Body,
ContentMD5,
ContentType,
...rest
});
return await client.send(command);
}