Skip to content

Instantly share code, notes, and snippets.

@ryan-k8
Created April 10, 2022 09:51
Show Gist options
  • Save ryan-k8/aac6e402118a9fafd9532bf0602ef961 to your computer and use it in GitHub Desktop.
Save ryan-k8/aac6e402118a9fafd9532bf0602ef961 to your computer and use it in GitHub Desktop.
filesystem api
async getFileStream(file) {
return {stream:URL.createObjectURL(file),type:file.type}
}
async function getDir() {
const dirHandle = await window.showDirectoryPicker();
for await (const entry of dirHandle.values()) {
if(entry.kind=='directory') {
console.log('directory--------',entry.name)
for await(const subentry of entry.values()) {
console.log(subentry.name);
}
} else {
const file = await entry.getFile();
const fileStream=getFileStream(file);
console.log(fileStream);
}
}
// run code for dirHandle
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment