Last active
December 22, 2021 03:43
-
-
Save halkyon/6eba8e17b5e1b537a10f9a0f24a6fd81 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; | |
// generate credentials with: | |
// uplink share --readonly=false --not-after +1h --register sj://mybucket/7702ec60-62ac-11ec-be04-7d227eabec45/ --auth-service=https://auth.us1.storjshare.io --access MYACCESS | |
const accessKeyId = "" | |
const secretAccessKey = "" | |
const endpoint = "https://gateway.us1.storjshare.io" | |
const s3Client = new S3Client({ | |
credentials: { | |
accessKeyId, | |
secretAccessKey | |
}, | |
region: "us-east-1", | |
endpoint: endpoint, | |
}); | |
s3Client.middlewareStack.add( | |
(next, _) => async (args) => { | |
console.log("Sending request from AWS SDK", {request: args.request}); | |
return next(args); | |
}, | |
{ | |
step: "finalizeRequest", | |
name: "logCalls", | |
} | |
); | |
const bucketName = "mybucket" | |
const keyFolder = "7702ec60-62ac-11ec-be04-7d227eabec45" | |
const key = "testfile.dat" | |
const config = { | |
Bucket: bucketName, | |
Key: `${keyFolder}/${key}`, | |
Body: "test", | |
}; | |
await s3Client.send(new PutObjectCommand(config)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment