File size: 973 Bytes
d6da254
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* 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)
  }
}