import AWS from 'aws-sdk';
// 配置 S3 客户端
const s3 = new AWS.S3({
  accessKeyId: 'admin',
  secretAccessKey: 'admin123',
  endpoint: 'http://localhost:9000',
  s3ForcePathStyle: true, // 使用路径样式的 URL
  signatureVersion: 'v4',
});

const main = async () => {
  const res = await s3
    .listObjectsV2({
      Bucket: 'mark',
      Prefix: 'mark/common',
    })
    .promise();
  console.log(res);
};
const getObject = async () => {
  const res = await s3
    .getObject({
      Bucket: 'mark',
      Key: 'mark/common/alist.md',
    })
    .promise();
  const content = res.Body?.toString();
  console.log(content);
};

// main();
// getObject();

const updateObject = async () => {
  const res = await s3
    .putObject({
      Bucket: 'mark',
      Key: 'common/b.md',
      Body: 'this is a test4',
    })
    .promise();
  console.log(res);
};

// updateObject();
