FileSaver.js icon indicating copy to clipboard operation
FileSaver.js copied to clipboard

save file without extension

Open iKrushYou opened this issue 6 years ago • 7 comments

is it possible to save a file without an extension? It seems like if I don't specify one it defaults to .txt

let blob = new Blob([atob(passwordInfo.private_key_base64)], {type: "text/plain;charset=utf-8"});
saveAs(blob, "pk_" + server.name);

iKrushYou avatar Sep 19 '19 19:09 iKrushYou

try changing/removing the text/plain?

jimmywarting avatar Sep 20 '19 08:09 jimmywarting

thanks @jimmywarting for the response. That didn't seem to work, unfortunately.

New code:

onClick={() => {
  let blob = new Blob([atob(passwordInfo.private_key_base64)], {type: "charset=utf-8"});
  saveAs(blob, "id_" + server.name);
}}

iKrushYou avatar Sep 20 '19 16:09 iKrushYou

Try changing let blob = new Blob([atob(passwordInfo.private_key_base64)], {type: "text/plain;charset=utf-8"}); saveAs(blob, "pk_" + server.name);

The "text/plain" in the original, to be "text/text"

henry7720 avatar Oct 20 '19 01:10 henry7720

Hi!

I face the same issue, it's only in Chrome (should be in Chromium based browsers, I only tested Chrome). The issue does not happen in Firefox. It's traced in these two issues (and surely some more) :

  • https://bugs.chromium.org/p/chromium/issues/detail?id=38213
  • https://bugs.chromium.org/p/chromium/issues/detail?id=1503

Given the dates, I have no hope of a fix.

I tried Henry's idea but no luck.

petosorus avatar Jul 06 '20 15:07 petosorus

I am downloading an epub toc.ncx file. I got FS to use .ncx file extension by changing "text/plain;charset=utf-8" to "text/ncx;charset=utf-8", using Chrome.

maddogandnoriko avatar Apr 09 '22 19:04 maddogandnoriko

If you want to save a file without an extension you can set the type to application/octet-stream.

pearsonradu avatar Oct 10 '23 14:10 pearsonradu

I tried using {type : "plain/plain"} and for some reason it worked... I don't know how

ap-berry avatar Oct 13 '23 09:10 ap-berry