Skip to content

Instantly share code, notes, and snippets.

@halkyon
Last active December 22, 2021 03:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save halkyon/6eba8e17b5e1b537a10f9a0f24a6fd81 to your computer and use it in GitHub Desktop.
Save halkyon/6eba8e17b5e1b537a10f9a0f24a6fd81 to your computer and use it in GitHub Desktop.
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