Giter VIP home page Giter VIP logo

browser-fs-access's Introduction

Browser-FS-Access

This module allows you to easily use the File System Access API on supporting browsers, with a transparent fallback to the <input type="file"> and <a download> legacy methods. This library is a ponyfill.

Read more on the background of this module in my post Progressive Enhancement In the Age of Fugu APIs.

Live Demo

Try the library in your browser: https://googlechromelabs.github.io/browser-fs-access/demo/.

Installation

You can install the module with npm.

npm install --save browser-fs-access

Usage Examples

The module feature-detects support for the File System Access API and only loads the actually relevant code.

Importing what you need

Import only the features that you need. In the code sample below, all features are loaded. The imported methods will use the File System Access API or a fallback implementation.

import {
  fileOpen,
  directoryOpen,
  fileSave,
  supported,
} from 'https://unpkg.com/browser-fs-access';

Feature detection

You can check supported to see if the File System Access API is supported.

if (supported) {
  console.log('Using the File System Access API.');
} else {
  console.log('Using the fallback implementation.');
}

Opening a file

const blob = await fileOpen({
  mimeTypes: ['image/*'],
});

Opening multiple files

const blobs = await fileOpen({
  mimeTypes: ['image/*'],
  multiple: true,
});

Opening files of different MIME types

const blobs = await fileOpen([
  {
    description: 'Image files',
    mimeTypes: ['image/jpg', 'image/png', 'image/gif', 'image/webp'],
    extensions: ['.jpg', '.jpeg', '.png', '.gif', '.webp'],
    multiple: true,
  },
  {
    description: 'Text files',
    mimeTypes: ['text/*'],
    extensions: ['.txt'],
  },
]);

Opening all files in a directory

Optionally, you can recursively include subdirectories.

const blobsInDirectory = await directoryOpen({
  recursive: true,
});

Saving a file

await fileSave(blob, {
  fileName: 'Untitled.png',
  extensions: ['.png'],
});

Saving a Response that will be streamed

const response = await fetch('foo.png');
await fileSave(response, {
  fileName: 'foo.png',
  extensions: ['.png'],
});

Saving a Promise<Blob> that will be streamed.

No need to await the Blob to be created.

const blob = createBlobAsyncWhichMightTakeLonger(someData);
await fileSave(blob, {
  fileName: 'Untitled.png',
  extensions: ['.png'],
});

API Documentation

Opening files:

// Options are optional. You can pass an array of options, too.
const options = {
  // List of allowed MIME types, defaults to `*/*`.
  mimeTypes: ['image/*'],
  // List of allowed file extensions (with leading '.'), defaults to `''`.
  extensions: ['.png', '.jpg', '.jpeg', '.webp'],
  // Set to `true` for allowing multiple files, defaults to `false`.
  multiple: true,
  // Textual description for file dialog , defaults to `''`.
  description: 'Image files',
  // Suggested directory in which the file picker opens. A well-known directory, or a file or directory handle.
  startIn: 'downloads',
  // By specifying an ID, the user agent can remember different directories for different IDs.
  id: 'projects',
  // Include an option to not apply any filter in the file picker, defaults to `false`.
  excludeAcceptAllOption: true,
};

const blobs = await fileOpen(options);

Opening directories:

// Options are optional.
const options = {
  // Set to `true` to recursively open files in all subdirectories, defaults to `false`.
  recursive: true,
  // Open the directory with `"read"` or `"readwrite"` permission, defaults to `"read"`.
  mode:
  // Suggested directory in which the file picker opens. A well-known directory, or a file or directory handle.
  startIn: 'downloads',
  // By specifying an ID, the user agent can remember different directories for different IDs.
  id: 'projects',
  // Callback to determine whether a directory should be entered, return `true` to skip.
  skipDirectory: (entry) => entry.name[0] === '.',
};

const blobs = await directoryOpen(options);

The module also polyfills a webkitRelativePath property on returned files in a consistent way, regardless of the underlying implementation.

Saving files:

// Options are optional. You can pass an array of options, too.
const options = {
  // Suggested file name to use, defaults to `''`.
  fileName: 'Untitled.txt',
  // Suggested file extensions (with leading '.'), defaults to `''`.
  extensions: ['.txt'],
  // Suggested directory in which the file picker opens. A well-known directory, or a file or directory handle.
  startIn: 'downloads',
  // By specifying an ID, the user agent can remember different directories for different IDs.
  id: 'projects',
  // Include an option to not apply any filter in the file picker, defaults to `false`.
  excludeAcceptAllOption: true,
};

// Optional file handle to save back to an existing file.
// This will only work with the File System Access API.
// Get a `FileHandle` from the `handle` property of the `Blob`
// you receive from `fileOpen()` (this is non-standard).
const existingHandle = previouslyOpenedBlob.handle;

// Optional flag to determine whether to throw (rather than open a new file
// save dialog) when `existingHandle` is no longer good, for example, because
// the underlying file was deleted. Defaults to `false`.
const throwIfExistingHandleNotGood = true;

// `blobOrPromiseBlobOrResponse` is a `Blob`, a `Promise<Blob>`, or a `Response`.
await fileSave(
  blobOrResponseOrPromiseBlob,
  options,
  existingHandle,
  throwIfExistingHandleNotGood
);

File operations and exceptions

The File System Access API supports exceptions, so apps can throw when problems occur (permissions not granted, out of disk space,…), or when the user cancels the dialog. The legacy methods, unfortunately, do not support exceptions (albeit there is an HTML issue open for this request). If your app depends on exceptions, see the file index.d.ts for the documentation of the legacySetup parameter.

Browser-FS-Access in Action

You can see the module in action in the Excalidraw drawing app.

excalidraw

It also powers the SVGcode app that converts raster images to SVGs.

svgcode

Alternatives

A similar, but more extensive library called native-file-system-adapter is provided by @jimmywarting.

Ecosystem

If you are looking for a similar solution for dragging and dropping of files, check out @placemarkio/flat-drop-files.

Acknowledgements

Thanks to @developit for improving the dynamic module loading and @dwelle for the helpful feedback, issue reports, and the Windows build fix. Directory operations were made consistent regarding webkitRelativePath and parallelized and sped up significantly by @RReverser. The TypeScript type annotations were initially provided by @nanaian. Dealing correctly with cross-origin iframes was contributed by @nikhilbghodke and @kbariotis. The exception handling of the legacy methods was contributed by @jmrog. The streams and blob saving was improved by @tmcw.

License and Note

Apache 2.0.

This is not an official Google product.

browser-fs-access's People

Contributors

amatewasu avatar barba828 avatar bates64 avatar christianliebel avatar dependabot[bot] avatar developit avatar dmihalcik-virtru avatar dwelle avatar fvilers avatar jmrog avatar kbariotis avatar niedzielski avatar nikhilbghodke avatar raid avatar rreverser avatar rwv avatar seanaye avatar simon-lammes avatar skratchdot avatar soulofmischief avatar steveruizok avatar tclangv avatar tmcw avatar tomayac avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

browser-fs-access's Issues

How to serialize file handles?

The article at web.dev mentions that file handles are serializable, and can be stored in IndexedDB (and presumably chrome.storage?), but there's no example and I haven't been able to make this work. What is the procedure for serializing the file handles for storage?

Problem using `browser-fs-access` in jest

Hi There,

I'm using jest for testing and having trouble with importing the browser-fs-access library.

    Jest encountered an unexpected token

    This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

    By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

    Here's what you can do:
     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     • If you need a custom transformation specify a "transform" option in your config.
     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/en/configuration.html

    Details:

    <root>/node_modules/browser-fs-access/dist/index.js:2
    export { fileOpen } from "./file-open.mjs";
    ^^^^^^

    SyntaxError: Unexpected token 'export'

This seems to be a common issue, documented here: jestjs/jest#2550, however, the common solutions don't work.

I tried to use the following configuration parameter to account for presence of mjs files but still getting the same error. Any thoughts on how to allow jest to successfully compile browser-fs-access?

 "transformIgnorePatterns": [
   "node_modules/(?!browser-fs-access).+(js|jsx|mjs|ts)$"
 ]

fileOpen() function doesn't reject promise when user dismiss file picker prompt without selecting a file

The API works fine when selecting files and also handles rejection when the chosen file is not valid, but when the user dismiss the file picker prompt without selecting any file, execution gets stuck in await fileOpen().

Code sample:

let fileHandle;
try {
   fileHandle = await fileOpen({
     mimeTypes: ['text/csv'],
     extensions: ['.csv'],
   });
} catch(error) {
   console.log(error); // Nothing happens here
}

AC:
Reject promise in fileOpen function when file picker prompt is dismissed

Add Streams API Support

Using the streams API is it possible to pipe data into a file handler e.g.

const fileHandle = await showSaveFilePicker();
const writableStream = await fileHandle.createWritable();
compressedStream.pipeTo(writableStream);

Could we add support for passing a stream to this library to more efficiently handle saving large files.
Obviously passing a stream in legacy mode would either need to reject or build a blob from the stream and save that.

Would this been considered within the scope of this library? I'm open to working on a PR

nativefs fileSave ignores options.mimeTypes

fileSave (unlike fileOpen) with the new API doesn't implement options.mimeTypes: https://github.com/GoogleChromeLabs/browser-nativefs/blob/f7cb5883c87d179f705e93414c351e1d363641f0/src/nativefs/file-save.mjs#L31

On Chrome Windows (at least), this gives a discrepancy between opening (.bin and text/plain give what I would expect):
image
And saving using the file handle given by the above fileOpen (same options):
image
I opened a .bin file, so the MIME type application/octet-stream (I assume) was used and suddenly Windows is prompting me to save the file as a .exe too!

Need to update types

fileOpen() and fileSave() now either take an options object, or an array of options objects. The types need to reflect this new change.

// New as of v0.20.0
fileOpen([
    {
      description: 'Image files',
      mimeTypes: ['image/jpg', 'image/png', 'image/gif', 'image/webp'],
      extensions: ['.jpg', '.jpeg', '.png', '.gif', '.webp'],
      multiple: true,
    },
    {
      description: 'Text files',
      mimeTypes: ['text/*'],
      extensions: ['.txt'],
    },
]);

or

// Previous behavior
fileOpen({
  description: 'Image files',
  mimeTypes: ['image/jpg', 'image/png', 'image/gif', 'image/webp'],
  extensions: ['.jpg', '.jpeg', '.png', '.gif', '.webp'],
  multiple: true,
});

Is there a way to get just the path of the selected folder?

I am trying to get a string path from the selected directory using showDirectoryPicker(), I do not want to upload anything I just need the selected path.

Does broswer-fs-access have this feature?
Or do you know how to get selected path from const dirHandle = await window.showDirectoryPicker() I am able to get the dirHandle but I cannot find a method or property that gives me the selected directory path.

TY

Ability to exclude folders when opening a directory recursively

It would be nice to add the ability to exclude some folders when opening a directory recursively.

We could, for example, exclude the .git directory of a folder, etc.

I think a list of strings with the folder names to exclude could be a good start for this feature.

Describe differences to directly working with the File System Access API in README

Hi :D If you're ok, I'd like to have a small PR to add a small section to the README regarding the migration from the native file system.

Thing is, I used the native file system first, then as my app needs to go live, I adopt this library, and there are several things I learned that I think would be useful for others in similar situation.

For example:

  • In the native API, the main model is "handle", and you get the file content from there, async
  • In this API, the main model is the file itself, and the "handle" is an optional object
  • Stuff like persisting to local storage (indexed DB actually)

directoryOpen gives up on large directories

This seems absurd but I have a use case for the Filesystem Access API where I pass it a game folder and it reads all the whole folder recursively for all the files needed to load a map into a webGL instance.

The problem is the folder is ~2.5GB and has ~17,000 files. 2/10 times I open the folder directoryOpen will return an array with all ~17,000 files, the rest of the time the function seems to parse all the folders but stops and doesn't return anything.
This works 100% of the time on Firefox and Safari but in Chrome, latest stable and beta it rarely works.

No errors or warnings in the console, it just stops and doesn't return at all. Sometimes it will read all the folders successfully but not return at all, sometimes it will stop a few folders short of the total amount of folders.
This also happens from time to time with ~2000 files but not as often.

Is this something to do with too many promises being made at once or is this a deeper issue or some maximum limit in the API spec?

Another observation is that introducing an artificial delay with something like

const delay = (ms: number) => new Promise(resolve => setTimeout(resolve, ms)) delay(100)

Increases the chance of the function returning anything by a lot, obviously this takes far longer to load the files. Any ideas? Thanks!

Add check if app is running in third- or first-party environment

Tried embedding excalidraw inside an frame and file loading and saving started throwing an error in Chrome but works on firefox.

Failed to execute 'showOpenFilePicker' on 'Window': Cross origin sub frames aren't allowed to show a file picker.

On further inspection, it looks like the underlying error is because of using showOpenFilePicker being used by this library.

Tried to repro on codesandbox here - https://codesandbox.io/s/exciting-hertz-jzjeg?file=/src/index.js (works on firefox but not on chrome)

SSR support

When using this library with a server-side-rendering module, it fails to load in webpack because of references to "self".

Possible to use in Chrome extension?

Hi, this is a great little library, but since it uses import to do its thing, it's difficult if not impossible to use in a Chrome extension (which I'm currently developing), because there's no way to set the file type to 'module' in the extension manifest. This needs to run in the content script, and injecting a script tag into the DOM has some big limitations.

Is there any way to use the current code in an extension, or could parts of it be extracted to work as simple functions in a standard JS file?

fileSave doesn't write correct mimeType for custom extensions

I'm not sure if this is a problem with Native FS API or something else, but if you save a blob with a given mimeType, but a custom extension, the file will end up with an empty/missing mimeType (when later opened, for example).

This should be reported upstream/crbug — just wanted to make sure I'm not missing something, first.

fileSave(new Blob([], { type: "application/json" }), {
    fileName: "test",
    extensions: [".excalidraw"]
})

const blob = await fileOpen({
    // if you comment this it won't even show the file
    // in file picker because of missing mimeType
    extensions: [".excalidraw"],
    mimeTypes: ["application/json"]
});
setType(blob.type); // ""

Repro: https://0cglk.csb.app/
Source: https://codesandbox.io/s/sharp-bartik-0cglk?file=/src/App.js (due to security, use the link above to test)

Demo page cannot import 'imageToBlob'

Hi, I read this article. Thank you for writing an interesting article and your contributions to the new Native File System API. However, I couldn't try demo page on Chrome (86.0.4220.0(Official Build)canary (x86_64)).
Console shows me the below error message.

Uncaught SyntaxError: The requested module 'https://unpkg.com/browser-nativefs' does not provide an export named 'imageToBlob'

I guess that imageToBlob cannot be used due to this change (#16).

If the demo page was broken unintentionally, please fix the demo page or export imageToBlob.

Unable to complete previous operation due to low memory

This happens periodically after opening the file explorer (and selecting a file of any size, even small (~10KB)) or camera.
Trace is not recorded due to browser restart.

Application version:
Chrome 92.0.4515.131

Operating system:
Android 9

Phone memory:

Reading a file using ReadableStream

I try the following to read a picked file in chunks:

const options: FirstFileOpenOptions<false> = {
	startIn: 'desktop',
	id: 'sendFile'
};

const file = await fileOpen(options);

const logChunks = async (readable: NodeJS.ReadableStream) => {
	for await (const chunk of readable) {
		console.log("Chunk: " + chunk.length);
	}
};

let stream = file.stream();
logChunks(stream);

This doesn't work neither in Edge nor in Firefox. file.stream() returns a ReadableStream object but it doesn't seem to have any methods.

I also tried to use a variant with stream.on('data', ...) but this is also undefined.

Am I doing something totally wrong or is this usage just not supported yet by browsers?

List of accepted file types

Is it possible to allow multiple file types, separated in a list, with separate descriptions for each?

Of course, I can allow as many file types as I want, however I would like to follow what desktop programs do, and separate them out like this:
image
Not a deal breaker obviously, just wondering if it's even possible on the web

Safari Support Issues/limitations question ...

On Safari the fileOpen API works fine (the Upload file dialog show up), but when using the fileSave API the ​"Save As..." dialog only shows up when changing browser preferences

Is there any way to always shows up the "Save As...." dialog on Safari browser independent of browser preferences? Today we have to set "Preferences/General/File Download location" to "Ask for each download".

My current Safari version is 14.1.1

Unexpected token in legacy file-open and directory-open

Hi,

I'm using browser-fs-access with nuxt and got an error about unexpected tokens in legacy/file-open.mjs and legacy-directory-open.mjs.

export default async( e={})=>new Promise(((t,n)=>{const i=document.createElement("input");i.type="file";const s=[...e.mimeTypes?e.mimeTypes:[],e.extensions?e.extensions:[]].join();let c;i.multiple=e.multiple||!1,i.accept=s||"";const l=()=>c(n);e.setupLegacyCleanupAndRejection&&(c=e.setupLegacyCleanupAndRejection(l)), i.addEventListener("change",(()=>{c?.(),t(i.multiple?Array.from(i.files):i.files[0])})),i.click()}));

The problem is the ? Operator

c?.(),t(i.multiple?Array.from(i.files):i.files[0])})),i.click() // doesn't work
c(),t(i.multiple?Array.from(i.files):i.files[0])})),i.click() // works

I'm not sure why webpack is complaining about, because it's valid javascript.

Extension contains invalid characters

TypeError: Failed to execute 'showOpenFilePicker' on 'Window': Extension '.mscz,' contains invalid characters. is the error I'm receiving. Obviously this has to do with how there's a comma at the end of the file extension, which is a real thing. You should consider allowing special characters in file extensions.

image
image

Demo does not work in Chrome on elementary os (ubuntu?)

The demo https://browser-fs-access.glitch.me/ does not work for me in Chrome. When I click on the following buttons, nothing happens, only the console prints The user aborted a request:

  • Open Image File
  • Open Image Files
  • Save Image File

This buttons work:

  • Open Image or Text Files
  • Open Directory

In Firefox everything works as excepted.

I come from excalidraw where I had the same problem (excalidraw/excalidraw#4112). There I get a Failed to execute 'showSaveFilePicker' on 'Window': Must be handling a user gesture to show a file picker. Error when I try to save a file as images.

I think the problem is related to this #38. In this demo mentioned in the comment #38 (comment), saving as image works for me.


Chrome Version: 95.0.4638.54
OS Version: elementary os 6 (based on Ubuntu 20.04.3 LTS)

'self is not defined' in Nuxt SSG

Since Nuxt Universal(SSR/SSG) create page on server side, openFile function failed in Nuxt project

Reference Error : self is not defined

To deal with this error, I added a conditional branch in supported.mjs of in node_modules and it works well.

// @license © 2020 Google LLC. Licensed under the Apache License, Version 2.0.
let e;
if(process.browser) {
  e="chooseFileSystemEntries"in self?"chooseFileSystemEntries":"showOpenFilePicker"in self&&"showOpenFilePicker";
}

export default e;

I'm going to send PR soon

Utilizing fileSave with no premade blob.

Hi,

I have tried within a little application to render the window.showSaveFilePicker utilising the fileSave method of the ponyfill.
However I cannot seem to circumvent the issue of not being able to provide a blob (even with i utilize new Blob the promise errors)

Are there any tips on how to utilize the fileSave method without passing a blob, as I would like to generate a file on the users machine - in the same manner as it's possible with the Text Editor sample.

Not saving but downloading file

Trying to copy library and demo to my place, but without success.
'Open Directory' => not open folder dialog
'Save Image File' => just downloading file, not saving in "selected" folder

Ability to abort a `directoryOpen`

When calling the function directoryOpen({ recursive: true }) and the user selects a large folder (such as C:\ for Windows users for example), it will try to load too many files and the promise will not resolve.

It would be great to add the ability to abort.
I don't know what could be exactly the best parameters to add, but I can think of:

  • maxFiles: natural int (after maxFiles found, either the promise resolves prematurely or rejects (second option is best imo))
  • timeout: natural int (after timeout ms, the promise is rejected?)
  • check (a callback that is called with some information about the folder, such as its name, and then if the callback returns a falsy value, the promise is rejected before opening the recursive folders?)

`change` event sometimes never fires on Safari

Hard to reproduce this one and is may be tied to specific hardware and time (i.e. SSD access speed). I've reproduced on MacOS Safari 14, and iPadOS Safari 14.

Repro case, especially after reload:

https://codesandbox.io/s/reverent-yalow-tk2rp?file=/src/App.js

I can also reproduce on Excalidraw (loading a scene from file).


One way to handle this is to add an interval checking the input.files and resolving if it contains any file:

https://codesandbox.io/s/determined-scott-wfp6o?file=/src/App.js

Strange thing is once this interval is set up it pretty much never reproduces (though it's really hard to disprove a false negative).

Using the setInterval hack would require having an abort handler again. Provided we don't want to do all that here, I propose passing the input into the setupLegacyCleanupAndRejection() (and rename the method to something like legacySetup) so that we can do these hacks ourselves in the host apps.

Purpose of `opts.extensions`?

When calling fileOpen, AFAIK the extensions doesn't really do anything on top of mimeTypes. At least on Windows (via Excalidraw) it does not.

What is it supposed to do, and why do/should we supply both mimeTypes and extensions?

Erroneous typings for FileSystemHandlePermissionDescriptor

The typings for FileSystemHandlePermissionDescriptor do not seem to be correct. They currently look like this:

export interface FileSystemHandlePermissionDescriptor {
  fileSystemHandle: FileSystemHandle;
  mode: 'read' | 'readWrite';
}

But the working draft defines FileSystemHandlePermissionDescriptor like so:

dictionary FileSystemHandlePermissionDescriptor {
  FileSystemPermissionMode mode = "read";
};

In other words, there should be an (optional) mode property only; there should not be a fileSystemHandle property at all, and mode should not be required. Furthermore, the valid values for mode should be 'read' and 'readwrite'.

(As some additional corroboration, the MDN docs for queryPermission and requestPermission indicate the same thing.)

I think what went wrong originally is that FileSystemHandlePermissionDescriptor was confused with FileSystemPermissionDescriptor (note the absence of "Handle" in the latter); see here.

[EDIT: PR attached below.]

Docblocks swapped for fileSave

The docblocks are swapped around for the File System Access API and legacy instances of the fileSave functions:

  • fs-access/file-save.mjs says "Saves file to disk using the (legacy) File System Access API."
  • fs-access-legacy/file-save.mjs says "Saves file to disk using the File System Access API."

Thanks for a very useful package!

Index.js makes some build tools think that it is a CommonJS module instead of ESM

The index.js seems to be a CommonJS module to some build tools (notably Sveltekit's static adapter) because it does not have a .mjs suffix and there is no "type": "module" in the package.json. Two solutions are to add the module type to package.json, which would allow for the removal of all .mjs suffixes, or add an mjs suffix to index.js.

Explore adding a File and Directory Entries API backend

The old File and Directory Entries API is very similar to the new API and allows most of thethings that File System Access API allows, too (e.g. iterating over directories, representing hierarchies, reading / creating files and dirs and so on).

While the FileWriter part of the API has been implemented only in Chrome, all the read-only bits are supported in Firefox and Safari too (https://caniuse.com/?search=filesystem), making it a feasible fallback backend to cover even more of the API surface and to make almost feature-complete polyfill.

The only downside is that the File and Directory Entries API only returns entries for drag&dropped items, not for those selected via <input type="file">. But perhaps this would be enough to cover some common use-cases?

default All Files(*.*) not working with fileOpen method in Chrome 86

Prerequisite:
Chrome v86

Steps to reproduce:
call fileOpen method without any options as below,
const filehandle = await fileOpen();

Observations:
when i debug the library source underhood this code logic seems to be the root cause,

window.showOpenFilePicker({ types: [ { description: '', accept: { '*.*':[]} } ], multiple: false });

Ref Original Source: https://github.com/GoogleChromeLabs/browser-nativefs/blob/master/src/nativefs/file-open.mjs

image

Expected behavior:
we don't need to set All Files(*.*) filter manually in FilePicker API that is handled by default right. please provide the fix.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.