MinIO
Install
| npm install @testcontainers/minio --save-dev
|
Examples
These examples use the following libraries:
Choose an image from the container registry and substitute IMAGE
.
Upload a file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 | await using container = await new MinioContainer(IMAGE).start();
const client = new minio.Client({
endPoint: container.getHost(),
port: container.getPort(),
useSSL: false,
accessKey: "minioadmin",
secretKey: "minioadmin",
});
const testFile = `${__dirname}/dummy-file.txt`;
await client.makeBucket("test-bucket");
await client.fPutObject("test-bucket", "minio-test-file.txt", testFile);
const objectExists = await client
.statObject("test-bucket", "minio-test-file.txt")
.then(() => true)
.catch(() => false);
expect(objectExists).toBeTruthy();
|
With credentials
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 | await using container = await new MinioContainer(IMAGE)
.withUsername("AzureDiamond")
.withPassword("hunter2!")
.start();
const client = new minio.Client({
endPoint: container.getHost(),
port: container.getPort(),
useSSL: false,
accessKey: "AzureDiamond",
secretKey: "hunter2!",
});
await client.makeBucket("test-bucket");
const bucketExits = await client.bucketExists("test-bucket");
expect(bucketExits).toBeTruthy();
|