Skip to content
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

suggest a default filename when saving #80

Closed
jimmywarting opened this issue Aug 16, 2019 · 10 comments · Fixed by #287
Closed

suggest a default filename when saving #80

jimmywarting opened this issue Aug 16, 2019 · 10 comments · Fixed by #287
Labels
feature - file picker Improvements to the file/directory picker
Milestone

Comments

@jimmywarting
Copy link

I didn't find anything about saving a file with a suggested filename in the spec

You should be able to suggest a filename when you want the user to save something
chooseFileSystemEntries({ type:'saveFile', name: 'documents.zip' })

the unknown filename is pretty bad if you don't know the extension and you won't be able to open it.
hence why i think saveFile is pretty bad and why i would only use openDirectory with write permission instead so i can specify the filename myself, but i don't want to enforce a filename or have write permission to a hole folder, users may not want to allow it.

@mkruisselbrink
Copy link
Contributor

Agreed that this does seem useful. Note that you can specify accepts in combination with type: 'saveFile', which does seem to result in the resulting file automatically getting the extension you specified.

@mkruisselbrink mkruisselbrink added this to the V1 milestone Aug 26, 2019
@opusonline
Copy link

This is the only missing feature that even the download attribute is ahead of ;)

@christianliebel
Copy link

Agreed that this does seem useful. Note that you can specify accepts in combination with type: 'saveFile', which does seem to result in the resulting file automatically getting the extension you specified.

The open file dialog seems to select the first format passed to accept. It would be cool if the website could also suggest the format preselection. This could be achieved by

  1. deriving it from the suggested filename’s extension
  2. adding the preferred format to the ChooseFileSystemEntriesOptions (the OpenFileDialog in .NET has a FilterIndex property allowing to preselect the format https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.openfiledialog?view=netframework-4.8#examples)

Manually reordering the array would not be very helpful, as this would also change the sorting of the formats in the file open dialog.

@christianliebel
Copy link

Also, it would be interesting to know which format the user has chosen. What’s the plan here?

  • Looking at the type of the associated File?
  • Reversely parse it from the extension of the FileSystemHandle’s name?

Maybe this could be informally added to the spec.

@jimmywarting
Copy link
Author

Not related to the spec, but I think i found a (mac?) bug... tested out the new showSaveFilePicker in chrome canary with types to hint about the extension.

showSaveFilePicker({
  excludeAcceptAllOption: true,
  types: [{
    accept: {
      'image/jpg': [ "jpg" ]
    }
  }]
})

the filename it suggest was .jpe
tried the same thing using jpeg... the suggested filename extension become jfif

other extensions like webp and png works ok

@mkruisselbrink mkruisselbrink modified the milestones: V1, V2 Jul 16, 2020
@mkruisselbrink
Copy link
Contributor

@jimmywarting that sounds like https://bugs.chromium.org/p/chromium/issues/detail?id=1103133, which should be fixed now (the suggested extension should now be the first script specified extension).

@jhmaloney
Copy link

jhmaloney commented Oct 14, 2020

This may be a different issue but I'd like a way to supply the extension or, ideally, a suggested file name. This is for MicroBlocks (https://microblocks.fun), a blocks programming IDE for the micro:bit and similar boards. We use the extensions .ubp and .ubl for MicroBlocks projects and libraries and the extensions .hex and .uf2 for compiled binaries. By using "types: [{ accept: ..." in the options object I'm able to get Chrome 86 to fill in .upb and .hex but not the other two extensions. The .uf2 extensions is changed to .bin and the .ubl extension is changed to .text. Is there any way to force Chrome to use a specific extension?

@tomayac
Copy link
Contributor

tomayac commented Nov 3, 2020

This issue is one of the few blockers (example) for getting rid of the legacy <a download="filename.txt"> approach. I have opened crbug/1145102 to track this.

@yisibl
Copy link

yisibl commented Dec 9, 2020

Please support custom file name, which is very important for smooth migration from a download!

Because of the lack of this feature, I was very confused and distressed when migrating to the File System Access API for Chrome DevTools.

@mkruisselbrink
Copy link
Contributor

#261 has a proposal for an API for this, feedback welcome.

mkruisselbrink added a commit that referenced this issue Jan 22, 2021
mkruisselbrink added a commit that referenced this issue Jan 22, 2021
…#261)

* Add initial explainer for suggestedName, startIn and related options.

This describes a proposal for #85, #144, #94 amd #80.


Co-authored-by: a-sully <[email protected]>
Co-authored-by: Thomas Steiner <[email protected]>
github-actions bot added a commit that referenced this issue Jan 22, 2021
…related options. (#261)

* Add initial explainer for suggestedName, startIn and related options.

This describes a proposal for #85, #144, #94 amd #80.

Co-authored-by: a-sully <[email protected]>
Co-authored-by: Thomas Steiner <[email protected]>

SHA: 282dcba
Reason: push, by @mkruisselbrink

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
mkruisselbrink added a commit that referenced this issue Jun 4, 2021
github-actions bot added a commit that referenced this issue Jun 4, 2021
…er methods. (#287)

This adds the options as described in https://github.com/WICG/file-system-access/blob/main/SuggestedNameAndDir.md.

Fixes #85, fixes #144, fixes #94 and fixes #80

Co-authored-by: Austin Sullivan <[email protected]>

SHA: 3309115
Reason: push, by @mkruisselbrink

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature - file picker Improvements to the file/directory picker
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants