22 lines
611 B
TypeScript
22 lines
611 B
TypeScript
import { Client } from 'minio'
|
|
|
|
export async function createBucket(client: Client, bucketName: string) {
|
|
const exists = await client.bucketExists(bucketName)
|
|
if (!exists) {
|
|
await client.makeBucket(bucketName, '')
|
|
console.log(`Bucket "${bucketName}" created successfully.`)
|
|
} else {
|
|
console.log(`Bucket "${bucketName}" already exists.`)
|
|
}
|
|
}
|
|
|
|
const minioClient = new Client({
|
|
endPoint: 'minio.kevisual.cn',
|
|
port: 9000,
|
|
useSSL: false,
|
|
accessKey: 'admin',
|
|
secretKey: 'xiongxiao',
|
|
})
|
|
createBucket(minioClient, 'nocodb').catch((err) => {
|
|
console.error('Error creating bucket:', err)
|
|
}) |