0

I am planning a project where I will need to be able to access files from the File and Directory Entries API through the browser through URLs with actual file paths (unlike blobs) and the FileSystemEntry.toURL() satisfies that need. However, while researching I found that this method is deprecated.

What replacements are there for the function?

luek baja
  • 1,475
  • 8
  • 20
  • What is the problem with the `fullPath` property of `FileSystemEntry`? – t.niese Jul 17 '22 at 20:26
  • @t.niese Would I not need to create the URL first, or is it always active? Like, at any time could I just open "filesystem:https://myapplication.com/filename" without calling `toURL()`? – luek baja Jul 17 '22 at 21:24
  • What exactly do you mean by "*be able to access files through URLs*"? Where do you need to access them? – Bergi Jul 17 '22 at 22:06
  • @Bergi Through a browser, like what the toURL function does. – luek baja Jul 17 '22 at 23:27
  • @luekbaja You mean downloading the file? Opening it in a new tab? Embedding it in an iframe or img? [It seems there is no direct replacement](https://bugs.chromium.org/p/chromium/issues/detail?id=695508), you have to implement the respective operation yourself. – Bergi Jul 18 '22 at 00:10
  • 1
    Please show exactly how you were using this method, from how you were getting the FileSystemEntry. As said before, there is no replacement for this method, and the way to do something similar is indeed to build and store yourself the path and create a blob:URL from the file you'd get by navigating there. But that'd help to see how you were accessing the FileSystemEntry as this whole API is deprecated in favor of the new [FileSystem](https://fs.spec.whatwg.org/) API (which uses XXXHandle interfaces). – Kaiido Jul 18 '22 at 02:06
  • @Kaiido I have not written any code, I am just planning a project, and this feature is needed for the planned application to work. Also, is the FileSystem API you are referencing is different than the File and Directory Entries API? – luek baja Jul 18 '22 at 02:16
  • 1
    Yes completely different. So once again, what usage of this API did you intend to make? How were you planning on requesting access to these entries? What were you planning to do with it? From where (PWA, website etc.)? – Kaiido Jul 18 '22 at 02:18
  • @Kaiido I need to be able to take any web application code, such as an `index.html` file, a `main.css` file, and maybe a js file for example, and run that code in the browser, separate from my main application. So if the `index.html` file requests `main.css` through a link tag, the `main.css` file should be loaded. Or, if a js file imports another js file, those should be loaded as well. That is why I am not able to use blobs, because I need to be able to reference files by their actual name. – luek baja Jul 18 '22 at 02:27
  • As other have written, not exactly sure what you're trying to do here, but maybe the [Origin Private File System](https://web.dev/file-system-access/#accessing-the-origin-private-file-system) is a solution?! – DenverCoder9 Oct 05 '22 at 15:07

0 Answers0