lora-studio / src /lib /utils /upload_image.ts
enzostvs's picture
enzostvs HF staff
rework models + user + add comment stuffs
d6da254
raw
history blame
973 Bytes
/* eslint-disable @typescript-eslint/no-explicit-any */
import {
S3Client,
// PutObjectCommand,
ListBucketsCommand,
} from "@aws-sdk/client-s3";
export const uploadImage = async (file: {
name: string,
data: any
}) => {
// const bucketName = 'lora-studio-generations'
// const keyName = file.name + '.png'
// const putCommand = new PutObjectCommand({
// Bucket: bucketName,
// Key: keyName,
// Body: file.data
// })
const client = new S3Client({
credentials: {
accessKeyId: process.env.AWS_ACCESS_KEY_ID as string,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY as string
},
region: 'us-east-1',
})
const command = new ListBucketsCommand({
});
try {
// await client.send(putCommand)
const data = await client.send(command);
console.log(data);
// console.log('Successfully uploaded data to ' + bucketName + '/' + keyName)
} catch (err: any) {
console.error(err, err.stack)
}
}