Initialization

This commit is contained in:
HoshinoKoji 2025-03-10 16:45:39 +08:00
commit 53915aad25
5 changed files with 2170 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
dist/
node_modules/

14
index.html Normal file
View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script type="module">
import { createClient, upload } from './dist/s3simp.js';
const client = createClient('default');
</script>
</body>
</html>

2111
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

18
package.json Normal file
View File

@ -0,0 +1,18 @@
{
"name": "s3-simp",
"version": "1.0.0",
"type": "module",
"scripts": {
"build": "esbuild s3simp.js --bundle --minify --format=esm --outdir=dist",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"description": "",
"dependencies": {
"@aws-sdk/client-s3": "^3.758.0"
},
"devDependencies": {
"esbuild": "0.25.1"
}
}

25
s3simp.js Normal file
View File

@ -0,0 +1,25 @@
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);
}