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