minio get object to type file javascript in typescript

index.ts
import * as minio from 'minio';
import * as fs from 'fs';

const minioClient = new minio.Client({
    endPoint: 'minio-server-ip',
    port: 9000,
    useSSL: false,
    accessKey: 'your-access-key',
    secretKey: 'your-secret-key'
});

const bucketName = 'your-bucket-name';
const objectName = 'your-object-name';
const filePath = 'path-to-save-file';

const file = fs.createWriteStream(filePath);

minioClient.getObject(bucketName, objectName, function(err, dataStream) {
    if (err) {
        return console.log(err);
    }

    dataStream.pipe(file);
});
561 chars
25 lines

related categories

gistlibby LogSnag