Assuming that I am using the latest version of Electron, I need to access the Filesystem-API so that I can read potentially huge files (several Gigabytes) chunk-based .
I have already implemented a system, so that I could supply an offset and a length to the function. Furthermore an other requirement is that only a path can be supplied and not some actual file-object from a file-chooser (otherwise I could use pure JS).
So far I have tried to use the readFile-API (by the way - the data needs to be base64 encoded):
window.require('electron').remote.require('fs').readSync(path, {enoding:'base64'}, (err,data)=>{...})
The issue with this solution is that I cannot supply the offset/length...
You are using params of readFileSync instead of readSync
https://nodejs.org/api/fs.html#fs_fs_readsync_fd_buffer_offset_length_position
fs.open('your-file', 'r', (err, fd) => {
const data = fs.readSync(fd, buffer, bytesRead, size, bytesRead)
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.