Commit 3a3247a 1 parent 37233b1 commit 3a3247a Copy full SHA for 3a3247a
File tree 1 file changed +10
-2
lines changed
1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -88,8 +88,7 @@ export class FileTypeParser {
88
88
}
89
89
90
90
async fromBlob ( blob ) {
91
- const buffer = await blob . arrayBuffer ( ) ;
92
- return this . fromBuffer ( new Uint8Array ( buffer ) ) ;
91
+ return this . fromWebStream ( blob . stream ( ) ) ;
93
92
}
94
93
95
94
async fromStream ( stream ) {
@@ -101,6 +100,15 @@ export class FileTypeParser {
101
100
}
102
101
}
103
102
103
+ async fromWebStream ( webStream ) {
104
+ const tokenizer = await strtok3 . fromWebStream ( webStream ) ;
105
+ try {
106
+ return await this . fromTokenizer ( tokenizer ) ;
107
+ } finally {
108
+ await tokenizer . close ( ) ;
109
+ }
110
+ }
111
+
104
112
async toDetectionStream ( readableStream , options = { } ) {
105
113
const { default : stream } = await import ( 'node:stream' ) ;
106
114
const { sampleSize = minimumBytes } = options ;
You can’t perform that action at this time.
0 commit comments