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

Add support for 3mf #415

Merged
merged 1 commit into from
Jan 12, 2021
Merged

Add support for 3mf #415

merged 1 commit into from
Jan 12, 2021

Conversation

Ugzuzg
Copy link
Contributor

@Ugzuzg Ugzuzg commented Nov 20, 2020

It follows the Open Packaging Conventions, so the detection is very similar to docx or odt.

The 3D Model part name SHOULD contain two segments, the first being "/3D/" and the second with the extension ".model" on the last segment, for example "/3D/3dModel.model".
-- https://github.com/3MFConsortium/spec_core/blob/master/3MF%20Core%20Specification.md#22-part-naming-recommendations

https://www.iana.org/assignments/media-types/model/3mf

@Ugzuzg Ugzuzg marked this pull request as ready for review November 20, 2020 18:01
@@ -318,6 +318,13 @@ async function _fromTokenizer(tokenizer) {
};
}

if (zipHeader.filename.startsWith('3D/') && zipHeader.filename.endsWith('.model')) {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
if (zipHeader.filename.startsWith('3D/') && zipHeader.filename.endsWith('.model')) {
if (zipHeader.filename.startsWith('/3D/') && zipHeader.filename.endsWith('.model')) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's no leading slash in the filenames of any of the zip-based formats. The above will fail.
xlsx has the same implementation: https://github.com/sindresorhus/file-type/blob/master/core.js#L314-L319

Copy link
Collaborator

@Borewit Borewit left a comment

Choose a reason for hiding this comment

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

Looks good to me. Another way, to determine the file, would be search for [Content_Types].xml , unzip that file, parse the XML, use the content-types. But not feasible in this context, I think this is the best way indeed.

@Borewit Borewit merged commit 7f95cd2 into sindresorhus:master Jan 12, 2021
@Ugzuzg Ugzuzg deleted the feat/3mf branch January 12, 2021 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants