jimmywarting / native-file-system-adapter

File system, based on the spec reference implementation
https://jimmywarting.github.io/native-file-system-adapter/example/test.html
MIT License
484 stars 43 forks source link

feat: fix missing createWritable in safari #62

Closed jimmywarting closed 1 year ago

jimmywarting commented 1 year ago

Safari do have a OPFS but it's lacking any good method of writing things to it unless you are not using the syncAccessHandle that's only available in web workers.

This will patch/repair/polyfill the missing features in the broken api.

Mazuh commented 10 months ago

@jimmywarting any estimate of when you'll publish a stable version on NPM including this fix?

jimmywarting commented 10 months ago

oh... did i forget to publish?

sry about that. i have nothing else in the work that needs to be completed. expect a new release soon-ish

SargisPlusPlus commented 8 months ago

@jimmywarting I had an issue with this... I published the library myself to test out this code. In my react app, I have:

          const opfsRoot = await getOriginPrivateDirectory();
          const userDir = await opfsRoot.getDirectoryHandle('123', {
            create: true,
          });
           const fileHandle = await userDir.getFileHandle('test.txt', {
              create: true,
           });
          try {
            const writable = await fileHandle.createWritable();
          } catch (e) {
            console.log('****', e);
          }

This works in Chrome. But Safari (17.2) throws an error: **** NotFoundError: A requested file or directory could not be found at the time an operation was processed.

UPDATE: I think I may have found the issue. See comments.