minio get object to type file javascript in javascript

index.tsx
const Minio = require('minio');
const fs = require('fs');

const minioClient = new Minio.Client({
    endPoint: 'play.min.io',
    port: 9000,
    useSSL: true,
    accessKey: 'YOUR_ACCESS_KEY',
    secretKey: 'YOUR_SECRET_KEY'
});

const bucketName = 'your-bucket-name';
const objectName = 'file.jpg';
const filePath = 'downloaded-file.jpg';

minioClient.fGetObject(bucketName, objectName, filePath, function(err) {
    if (err) {
        return console.log(err);
    }
    console.log('File is successfully downloaded.');
});
528 chars
22 lines

Explanation: This code snippet demonstrates how to use the fGetObject method in the Minio JavaScript SDK to download an object (file) from a Minio bucket to the local file system. You need to provide your Minio server details (endPoint, port, accessKey, and secretKey), the name of the bucket where the object is located, the name of the object you want to download, and the local file path where the downloaded file will be stored.

related categories

gistlibby LogSnag