New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing file extension in download save dialog #10121

Closed
steverandy opened this Issue Jul 26, 2017 · 21 comments

Comments

Projects
None yet
@steverandy

steverandy commented Jul 26, 2017

  • Electron version: 1.7.5
  • Operating system: macOS 10.12.6

Expected behavior

Save dialog should show filename with the correct extension.

Actual behavior

Extension is missing in the filename on the save dialog window.

screen shot 2017-07-26 at 10 51 42 pm

How to reproduce

Download a file from a webview.

@zeke

This comment has been minimized.

Member

zeke commented Jul 26, 2017

@steverandy do you have Finder configured to show extensions?

screen shot 2017-07-26 at 2 26 26 pm

@deltaroe

This comment has been minimized.

deltaroe commented Jul 26, 2017

We've run into this as well on 1.7.4 and macOS 10.12

With "Show all filename extensions" enabled the extension is added when a file is downloaded, when it's off downloaded files are stripped of their extensions and saved as a bare filename.

Reverting to 1.6.11 resolves the issue for us

@steverandy

This comment has been minimized.

steverandy commented Jul 27, 2017

@zeke I don't have the finder config enabled.

When it is enabled, it fixes the issue.
Is this behavior somewhat controlled by the Finder?

@steverandy

This comment has been minimized.

steverandy commented Jul 29, 2017

I can confirm that the issue is present since v1.7.4.

@javan

This comment has been minimized.

Contributor

javan commented Jul 31, 2017

Confirmed here on macOS 10.12.6 + Electron 1.7.5 too. Curiously, it only happens in a packaged (with electron-packager in my case) .app. The file extension is present when launching the app locally with electron ..

@kevinsawicki

This comment has been minimized.

Contributor

kevinsawicki commented Aug 8, 2017

This looks like a possible regression from #9610, @shubham2892 would you be able to take a look?

@juanmnl

This comment has been minimized.

juanmnl commented Aug 23, 2017

Same here, macOS Sierra 10.12.6, electron v1.7.5

Finder's "show all filename extensions" fixes it, but I don't expect users to have it enabled by default.

@bennyn

This comment has been minimized.

bennyn commented Aug 29, 2017

Encountered the same issue with Electron 1.7.6. When Finder's "Show all filename extensions" is enabled, then files are saved as "file.txt". When the setting is disabled, files will get saved as "file" (without extension).

This behaviour has been different in the past (with Electron 1.6). At that time files were always saved with their extension.

@bennyn

This comment has been minimized.

bennyn commented Aug 29, 2017

I tried to cheat the save dialog the following way:

  1. Downloading file as Blob using XMLHttpRequest (with responseType of arraybuffer)
  2. Creating URL from the Blob (using URL.createObjectURL)
  3. Creating anchor tag with href property set to Blob URL
  4. Setting download property of anchor tag to fake filename
  5. Triggering click on anchor tag

Unfortunately it still doesn't work. You can test it in your own Electron app using the following snippet from the DevConsole within Electron:

const url = window.URL.createObjectURL(new Blob());
const anchor = document.createElement('a');
document.body.appendChild(anchor);
anchor.href = url;
anchor.download = 'file.txt';
anchor.style = 'display: none';
anchor.click();

Although anchor is set to the fixed value file.txt, it depends on the macOS Finder setting if the extension is shown in the save dialog or not.

@dengyaolong

This comment has been minimized.

Contributor

dengyaolong commented Aug 31, 2017

really harmful change~Many user feedback file download but can't open cause extend name is lost. Any hack?

@javan

This comment has been minimized.

Contributor

javan commented Sep 2, 2017

We've had customers report this issue on Windows 10 as well. There's a similar OS setting: http://www.thewindowsclub.com/show-file-extensions-in-windows

@MarshallOfSound

This comment has been minimized.

Member

MarshallOfSound commented Sep 2, 2017

I just spent a fair time trying to debug this, it looks like our dialog logic is correct (still) but is not being triggered by our download manager delegates. Will investigate more when I get a chance, at the moment my thoughts are somewhere in a Chromium update our code stopped being executed

@dengyaolong

This comment has been minimized.

Contributor

dengyaolong commented Sep 3, 2017

Now, I prompt the saveDialog and get the filename, add extend name(get by request) when no extend name set by use. Really strange, but work...

@marcoconti83

This comment has been minimized.

marcoconti83 commented Sep 4, 2017

Hey @dengyaolong,
thanks for the suggestion on how to "hack" a solution. Could you please explain more how you do it? Any code you can share with us?

@javan

This comment has been minimized.

Contributor

javan commented Sep 4, 2017

This looks like a possible regression from #9610

@MarshallOfSound, have you looked into that change as a possible cause?

@dengyaolong

This comment has been minimized.

Contributor

dengyaolong commented Sep 5, 2017

@marcoconti83

This comment has been minimized.

marcoconti83 commented Sep 5, 2017

@dengyaolong thanks!

@bennyn

This comment has been minimized.

bennyn commented Sep 7, 2017

@dengyaolong With your 'will-download' listener I am able to get the filename (plus it's extension). 🎉

However, the 'will-download' event only triggers for after the "Save as" dialog has been shown. Is it the same for you? Because I want to fill in the filename (including extension) beforehand.

@dengyaolong

This comment has been minimized.

Contributor

dengyaolong commented Sep 7, 2017

@bennyn I update the listener, now , you can set 'opts.dir' to set saveDir without dialog.
ps. just call item.setSavePath like my code. https://github.com/dengyaolong/electron-downloader/blob/master/index.js

@poiru

This comment has been minimized.

Member

poiru commented Sep 8, 2017

Fixed by #10469.

@BONDbATIF

This comment has been minimized.

BONDbATIF commented Jun 16, 2018

@steverandy @javan
I am using electron v1.8.4 in mac .Still extension issue is not fixed in mac .
Any update ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment