Created
April 10, 2022 09:51
-
-
Save ryan-k8/aac6e402118a9fafd9532bf0602ef961 to your computer and use it in GitHub Desktop.
filesystem api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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