Search code examples
node.jsexpressminio

i cant download minio generated link with a tag


i'm trying to download a something from minio browser with "a" tag while using download attribute. in this case i want to download a song, when i click on link, i redirect to play song page, but i see no download or save as pop up. if i copy the link and past that in idm(internet download manager), start to download the file.

i set the bucket policy => read only for *

it is the download link that generated https://5c6d9b4556185a0011c13b92.storage.liara.ir/singles/Ali%20Sorena%20-%20Aavaar(320)?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=V53B3X6JUVA1NSMG7SOAJ/20190417/us-east-1/s3/aws4_request&X-Amz-Date=20190417T104438Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=39db9a3041d351b03c7b71b8a68d37f1729374e9008be9a68d378f88fb043b50

and a tag:

<a href="https://5c6d9b4556185a0011c13b92.storage.liara.ir/singles/Ali%20Sorena%20-%20Aavaar(320)?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=V53B3X6JUVA1NSMG7SOAJ/20190417/us-east-1/s3/aws4_request&X-Amz-Date=20190417T104438Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=39db9a3041d351b03c7b71b8a68d37f1729374e9008be9a68d378f88fb043b50"
download>Download</a>

Solution

  • You will need to add a Content-Disposition header to force download (see How to Use Content-disposition for force a file to download to the hard drive?).

    You can apparently use the reqParams argument to add response-content-disposition.

    Something like this, maybe.

    liaraClient.presignedUrl(
      "GET",
      "mybucket",
      "myfile.mp3",
      { "response-content-disposition": "attachment; name=myfile.mp3" },
      24 * 60 * 60,
      (err, presignedUrl) => {
        if (err) return console.log(err);
        console.log(presignedUrl);
      },
    );