save-file icon indicating copy to clipboard operation
save-file copied to clipboard

Can't open file dialog with suggested filename

Open regosen opened this issue 4 years ago • 0 comments

I'm trying to use save-file to open a dialog with a suggested filename in the "Save As" field. I'm testing with Chrome on both macOS and Ubuntu. I started with your README example, as well as several variations:

import { save } from 'save-file'

const data = '{\n"message": "This is a test"\n}';
await save(data, 'test.json'); <-- saves directly to "~/Downloads/test.json", no prompt
await save(data); <-- opens prompt, but suggested filename is literally {_"message"_ "This is a test"_}, see below

const file = new File([data], 'test.json');
await save(file, 'test.json') <-- saves directly to "~/Downloads/test.json", no prompt
await save(file) <-- saves directly to "~/Downloads/test.json", no prompt

Screen Shot 2021-06-16 at 10 46 59 AM

Ideally it would open a dialog with the Save as field seeded with the filename. Is there a way to do this with save-file?

regosen avatar Jun 16 '21 17:06 regosen