Edits history of script submission #22498 for ' Get object in bucket as text (s3)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    import * as Minio from "minio@7";
    
    type S3 = {
      endPoint: string;
      port: number;
      useSSL: boolean;
      pathStyle: boolean;
      bucket: string;
      accessKey: string;
      secretKey: string;
      region: string;
    };
    export async function main(s3: S3, path: string) {
      const stream = await new Minio.Client(s3).getObject(s3.bucket, path);
      const chunks: Buffer[] = [];
      for await (const chunk of stream) {
        chunks.push(chunk as Buffer);
      }
      return Buffer.concat(chunks).toString("utf-8");
    }
    

    Submitted by hugo989 7 hours ago