Initialization
This commit is contained in:
commit
53915aad25
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
dist/
|
||||
node_modules/
|
14
index.html
Normal file
14
index.html
Normal 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
2111
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
18
package.json
Normal file
18
package.json
Normal 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
25
s3simp.js
Normal 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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user