add services/capture/src/s3/client.js

This commit is contained in:
Zac Gaetano 2026-04-07 21:58:30 -04:00
parent 75ef8a4ed8
commit dfffca879a

View file

@ -0,0 +1,32 @@
import { S3Client } from '@aws-sdk/client-s3';
import { Upload } from '@aws-sdk/lib-storage';
const s3Client = new S3Client({
endpoint: process.env.S3_ENDPOINT,
region: process.env.AWS_REGION || 'us-east-1',
credentials: {
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
},
forcePathStyle: true,
});
/**
* Create an upload stream for streaming data to S3
* @param {string} bucket - S3 bucket name
* @param {string} key - S3 object key
* @param {Stream} body - ReadableStream to upload
* @returns {Promise} Upload promise
*/
export function createUploadStream(bucket, key, body) {
return new Upload({
client: s3Client,
params: {
Bucket: bucket,
Key: key,
Body: body,
},
}).done();
}
export default s3Client;