Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avro file type support added #597

Merged
merged 4 commits into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {Readable as ReadableStream} from 'node:stream';
import type {ITokenizer} from 'strtok3';

export type FileExtension =
| 'avro'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be added to the end.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

| 'jpg'
| 'png'
| 'apng'
Expand Down Expand Up @@ -167,6 +168,7 @@ export type MimeType =
| 'image/vnd.ms-photo'
| 'image/vnd.adobe.photoshop'
| 'application/x-indesign'
| 'application/avro'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be added to the end.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

| 'application/epub+zip'
| 'application/x-xpinstall'
| 'application/vnd.oasis.opendocument.text'
Expand Down
14 changes: 14 additions & 0 deletions core.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,13 @@ class FileTypeParser {
};
}

if (this.check([0x4F, 0x62, 0x6A, 0x01])) {
return {
ext: 'avro',
mime: 'application/avro',
};
}

if (this.checkString('FLIF')) {
return {
ext: 'flif',
Expand Down Expand Up @@ -292,6 +299,13 @@ class FileTypeParser {
};
}

if (this.checkString('avro')) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you link to a source for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see it written anywhere there that the file header must start with avro.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After further research I think you are correct, it is not specified anywhere that the file header MUST end with avro.
I have removed that check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've also noticed people use .avsc and .acme, but I don't quite understand the difference

return {
ext: 'avro',
mime: 'application/avro',
};
}

// Zip-based file formats
// Need to be before the `zip` check
if (this.check([0x50, 0x4B, 0x3, 0x4])) { // Local file header signature
Expand Down
Binary file added fixture/fixture.avro
Binary file not shown.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@
"class",
"arj",
"cpio",
"ace"
"ace",
"avro"
],
"dependencies": {
"readable-web-to-node-stream": "^3.0.2",
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ Returns a `Set<string>` of supported MIME types.
- [`asf`](https://en.wikipedia.org/wiki/Advanced_Systems_Format) - Advanced Systems Format
- [`avi`](https://en.wikipedia.org/wiki/Audio_Video_Interleave) - Audio Video Interleave file
- [`avif`](https://en.wikipedia.org/wiki/AV1#AV1_Image_File_Format_(AVIF)) - AV1 Image File Format
- [`avro`](https://en.wikipedia.org/wiki/Apache_Avro#Avro_Object_Container_File) - Object container file developed by Apache Avro
- [`blend`](https://wiki.blender.org/index.php/Dev:Source/Architecture/File_Format) - Blender project
- [`bmp`](https://en.wikipedia.org/wiki/BMP_file_format) - Bitmap image file
- [`bpg`](https://bellard.org/bpg/) - Better Portable Graphics file
Expand Down
2 changes: 2 additions & 0 deletions supported.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const extensions = [
'avro',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was implied that #597 (comment) applied here too. And the below.

'jpg',
'png',
'apng',
Expand Down Expand Up @@ -162,6 +163,7 @@ export const mimeTypes = [
'image/bmp',
'image/vnd.ms-photo',
'image/vnd.adobe.photoshop',
'application/avro',
'application/x-indesign',
'application/epub+zip',
'application/x-xpinstall',
Expand Down