Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get actual image or video from minio server

Tags:

minio

I have uploaded some images and videos in the minio server (https://play.minio.io:9000) from my android client. Now I have been able to download the uploaded content from that folder. What I can see that the content is not the actual image/video, instead it shows me some encrypted format. My question is how can I get the actual image/video that I have uploaded. Is there any such tool or anything else I could do?

Any help would be appreciated..

Thanks in advance.

like image 220
Biplab Bhattacharya Avatar asked Oct 16 '22 10:10

Biplab Bhattacharya


1 Answers

Here is my solution for Image preview in minio

# set alias
mc alias set myminio HOST:9000 MINIO_CLIENT MINIO_SECRET

# create bucket
mc mb myminio/image

# set policy for the bucket
mc policy set download myminio/image

My uploader function

const fs = require('fs');
const file = './cat.jpg';
const fileStream = fs.createReadStream(file);

const metadata = {
  'Content-type': 'image',
};

const upload = async () => {
  const etag = await minioClient.putObject(
    'image',
    'cat.jpg',
    fileStream,
    metadata // this metadata in important to preview image from browser instead of download
  );
  console.log({ etag });
};

Now navigate to http://localhost:9000/image/cat.jpg

You will see your cat image from direct link.

like image 103
Naimur Rahman Avatar answered Oct 21 '22 03:10

Naimur Rahman