提交 49369873 编写于 作者: E Eugene Pankov

Update platform.service.ts

上级 0f2ba46d
......@@ -213,3 +213,38 @@ class ElectronFileUpload extends FileUpload {
this.file.close()
}
}
class ElectronFileDownload extends FileDownload {
private size: number
private file: fs.FileHandle
private buffer: Buffer
constructor (private filePath: string) {
super()
this.buffer = Buffer.alloc(256 * 1024)
}
async open (): Promise<void> {
this.size = (await fs.stat(this.filePath)).size
this.file = await fs.open(this.filePath, 'r')
}
getName (): string {
return path.basename(this.filePath)
}
getSize (): number {
return this.size
}
async read (): Promise<Buffer> {
const result = await this.file.read(this.buffer, 0, this.buffer.length, null)
this.increaseProgress(result.bytesRead)
console.log(result)
return this.buffer.slice(0, result.bytesRead)
}
close (): void {
this.file.close()
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册