file-type 20.0.0 → 20.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core.js +13 -11
- package/package.json +2 -2
- package/readme.md +5 -4
package/core.js
CHANGED
|
@@ -726,17 +726,19 @@ export class FileTypeParser {
|
|
|
726
726
|
|
|
727
727
|
if (this.checkString('%PDF')) {
|
|
728
728
|
try {
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
729
|
+
const skipBytes = 1350;
|
|
730
|
+
if (skipBytes === await tokenizer.ignore(skipBytes)) {
|
|
731
|
+
const maxBufferSize = 10 * 1024 * 1024;
|
|
732
|
+
const buffer = new Uint8Array(Math.min(maxBufferSize, tokenizer.fileInfo.size - skipBytes));
|
|
733
|
+
await tokenizer.readBuffer(buffer, {mayBeLess: true});
|
|
734
|
+
|
|
735
|
+
// Check if this is an Adobe Illustrator file
|
|
736
|
+
if (includes(buffer, new TextEncoder().encode('AIPrivateData'))) {
|
|
737
|
+
return {
|
|
738
|
+
ext: 'ai',
|
|
739
|
+
mime: 'application/postscript',
|
|
740
|
+
};
|
|
741
|
+
}
|
|
740
742
|
}
|
|
741
743
|
} catch (error) {
|
|
742
744
|
// Swallow end of stream error if file is too small for the Adobe AI check
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "file-type",
|
|
3
|
-
"version": "20.0.
|
|
3
|
+
"version": "20.0.1",
|
|
4
4
|
"description": "Detect the file type of a file, stream, or data",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "sindresorhus/file-type",
|
|
@@ -238,7 +238,7 @@
|
|
|
238
238
|
],
|
|
239
239
|
"dependencies": {
|
|
240
240
|
"@tokenizer/inflate": "^0.2.6",
|
|
241
|
-
"strtok3": "^10.0
|
|
241
|
+
"strtok3": "^10.2.0",
|
|
242
242
|
"token-types": "^6.0.0",
|
|
243
243
|
"uint8array-extras": "^1.4.0"
|
|
244
244
|
},
|
package/readme.md
CHANGED
|
@@ -256,15 +256,16 @@ console.log(fileType);
|
|
|
256
256
|
Or use [`@tokenizer/s3`](https://github.com/Borewit/tokenizer-s3) to determine the file type of a file stored on [Amazon S3](https://aws.amazon.com/s3):
|
|
257
257
|
|
|
258
258
|
```js
|
|
259
|
-
import
|
|
260
|
-
import {
|
|
259
|
+
import {S3Client} from '@aws-sdk/client-s3';
|
|
260
|
+
import {makeChunkedTokenizerFromS3} from '@tokenizer/s3';
|
|
261
261
|
import {fileTypeFromTokenizer} from 'file-type';
|
|
262
262
|
|
|
263
263
|
// Initialize the S3 client
|
|
264
|
-
|
|
264
|
+
// Initialize S3 client
|
|
265
|
+
const s3 = new S3Client();
|
|
265
266
|
|
|
266
267
|
// Initialize the S3 tokenizer.
|
|
267
|
-
const s3Tokenizer = await
|
|
268
|
+
const s3Tokenizer = await makeChunkedTokenizerFromS3(s3, {
|
|
268
269
|
Bucket: 'affectlab',
|
|
269
270
|
Key: '1min_35sec.mp4'
|
|
270
271
|
});
|