Home - Webxdc Specification

importFiles

let files = await window.webxdc.importFiles(filter);

importFiles() allows a webxdc app to import files. Depending on platform support, this just opens the system file picker or a custom one. This custom file picker should show recent attachments that were received and sent, to make importing of a file that you just received from someone easier (you don't need to save it to the file system first), but it also still shows a button to open the system file picker.

The method returns a Promise that resolves to an Array of File-Objects.

Example:

// then/catch
window.webxdc.importFiles({
  mimeTypes: ["text/calendar"],
  extensions: [".ics"],
}).then((files) => {
  /* do sth with the files */
}).catch((error) => {
    console.log(error);
});
// async/await
try {
  let files = await window.webxdc.importFiles({
    mimeTypes: ["text/calendar"],
    extensions: [".ics"],
  })
  /* do sth with the files */
} catch (error) {
  console.log(error);
}