@@ -9,7 +9,7 @@ import type {
|
||||
FileSystemGetFileOptions,
|
||||
FileSystemCreateWritableOptions,
|
||||
FileSystemWritableFileStream,
|
||||
File
|
||||
File as WebFile
|
||||
} from '@sugoidogo/importable-types-web'
|
||||
|
||||
export default class NodeFileSystemFileHandle extends NodeFileSystemHandle implements FileSystemFileHandle {
|
||||
@@ -24,13 +24,10 @@ export default class NodeFileSystemFileHandle extends NodeFileSystemHandle imple
|
||||
async createWritable(options: FileSystemCreateWritableOptions = {}): Promise<FileSystemWritableFileStream> {
|
||||
return new NodeFileSystemWritableFileStream(this.path,options)
|
||||
}
|
||||
async getFile(): Promise<File> {
|
||||
async getFile(): Promise<WebFile> {
|
||||
const stats = await asyncfs.stat(this.path)
|
||||
const type = mime.getType(this.name.split('.').pop())
|
||||
return asyncfs.readFile(this.path).then(buffer => Object.assign(new Blob([buffer], { type }), {
|
||||
lastModified: stats.mtimeMs,
|
||||
name: this.path,
|
||||
webkitRelativePath: this.path
|
||||
})) as unknown as File // TODO ArrayBufferView and DataView are incompatible types
|
||||
const buffer = await asyncfs.readFile(this.path)
|
||||
return new File([buffer], this.path, { "lastModified": stats.mtimeMs, "type": type }) as any //TODO Node File and Web File have some incompatibilities
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user