This commit is contained in:
2025-04-14 23:58:17 +08:00
commit b92686ce29
55 changed files with 2352 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
import AWS from 'aws-sdk';
import { Client } from 'minio';
const minioClient = new Client({
endPoint: 'localhost',
port: 9000,
useSSL: false,
accessKey: 'admin',
secretKey: 'admin123',
});
// const s3 = new AWS.S3({
// accessKeyId: 'admin',
// secretAccessKey: 'admin123',
// endpoint: 'http://localhost:9000',
// s3ForcePathStyle: true, // 使用路径样式的 URL
// signatureVersion: 'v4',
// });
// 监听事件
const listen = async () => {
const res = minioClient.listenBucketNotification('mark', 'common', '.md', [
's3:ObjectCreated:*', // 监听所有对象创建事件
// delete
's3:ObjectRemoved:*',
]);
res.on('notification', (event) => {
console.log(event);
});
// const res = await minioClient.getBucketNotification('mark');
// console.log(res);
};
listen();
const getList = async () => {
const res = minioClient.listObjectsV2('mark', 'common', true);
res.on('data', (event) => {
console.log(event);
});
};
// getList();