javascriptserializationpostmessagefile-system-access-api

File System Access API: how to send a fileHandle with postMessage?


I'm working with the File System Access API and I have to send a FileSystemDirectoryHandle calling a postMessage(), according to this article it seems to be possible

File handles are serializable, which means that you can save a file handle to IndexedDB, or call postMessage() to send them between the same top-level origin.

I made many try but... noway

In this question @DenverCoder9 proposes a working example for the indexedDb but I can't find anything for the postMessage

Thanks, Davide


Solution

  • According to this fixed bug transferring file handles via postMessage() is implemented and should work, however, only for same-origin contexts. If it doesn’t work, probably your origins are different.