1 | import * as Minio from "minio@7"; |
2 |
|
3 | type S3 = { |
4 | endPoint: string; |
5 | port: number; |
6 | useSSL: boolean; |
7 | pathStyle: boolean; |
8 | bucket: string; |
9 | accessKey: string; |
10 | secretKey: string; |
11 | region: string; |
12 | }; |
13 | export async function main(s3: S3, path: string) { |
14 | const stream = await new Minio.Client(s3).getObject(s3.bucket, path); |
15 | const chunks: Buffer[] = []; |
16 | for await (const chunk of stream) { |
17 | chunks.push(chunk as Buffer); |
18 | } |
19 | return Buffer.concat(chunks).toString("utf-8"); |
20 | } |
21 |
|