Created
November 12, 2025 13:06
-
-
Save alexey-sh/dccc1aa33dc128fa4435fee58dd622b6 to your computer and use it in GitHub Desktop.
Minio S3 Bearer
This file contains hidden or 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
| const { | |
| S3Client, | |
| PutObjectCommand, | |
| GetObjectCommand, | |
| ListObjectsV2Command, | |
| ListBucketsCommand, | |
| DeleteObjectCommand, | |
| } = require("@aws-sdk/client-s3"); | |
| const MINIO_CONFIG = { | |
| endpoint: process.env.MINIO_ENDPOINT, | |
| region: 'us-east-1', | |
| credentials: { | |
| accessKeyId: process.env.MINIO_ACCESS_KEY, | |
| secretAccessKey: process.env.MINIO_SECRET_KEY | |
| }, | |
| forcePathStyle: true, | |
| }; | |
| const BEARER_TOKEN = process.env.BEARER_TOKEN; | |
| const BUCKET_NAME = process.env.MINIO_BUCKET; | |
| const s3Client = new S3Client(MINIO_CONFIG); | |
| s3Client.middlewareStack.add( | |
| (next, context) => async (args) => { | |
| args.request.headers['x-bearer-token'] = BEARER_TOKEN; | |
| console.log(args.request); | |
| return next(args); | |
| }, | |
| { | |
| step: 'finalizeRequest', | |
| relation: 'before', | |
| tags: ['HANDLER'], | |
| name: 'addBearerTokenMiddleware' | |
| } | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment