silvester-23/src/lib/helpers/s3.ts

21 lines
554 B
TypeScript

import Minio from 'minio'
import { S3_ENDPOINT_URL, S3_SECRET_ACCESS_KEY, S3_BUCKET_NAME, S3_ACCESS_KEY } from "$env/static/private"
const minioClient = new Minio.Client({
endPoint: S3_ENDPOINT_URL,
port: 80,
useSSL: false,
accessKey: S3_ACCESS_KEY,
secretKey: S3_SECRET_ACCESS_KEY,
})
export function putObject(fileName: string, content: Buffer, metadata: Minio.ItemBucketMetadata = {}) {
return minioClient.putObject(S3_BUCKET_NAME, fileName, content, metadata);
}
export function listBuckets() {
return minioClient.listBuckets();
}