stargaze-studio/services/s3.ts
2022-07-13 16:56:36 +03:00

22 lines
537 B
TypeScript

import { PutObjectCommand, S3 } from '@aws-sdk/client-s3'
import { S3_BUCKET, S3_ENDPOINT, S3_KEY, S3_REGION, S3_SECRET } from 'utils/constants'
const PARAMS = {
Bucket: S3_BUCKET,
ACL: 'private',
}
const s3Client = new S3({
endpoint: S3_ENDPOINT,
region: S3_REGION,
credentials: {
accessKeyId: S3_KEY,
secretAccessKey: S3_SECRET,
},
})
export const uploadObject = async (key: string, body: string) => {
const data = await s3Client.send(new PutObjectCommand({ ...PARAMS, Key: key, Body: body }))
return data
}