petrbroz / svf-utils

Utilities for working with the SVF file format used by Autodesk Platform Services.
https://petrbroz.github.io/svf-utils/
MIT License
126 stars 54 forks source link

SVF assets urn may contain multibyte characters, so encode before sending request #10

Closed dykarohora closed 4 years ago

dykarohora commented 4 years ago

The SVF asset URN may contain multi-byte characters. (e.g. Revit project for Japanese edition) If multi-byte characters are included, the following error will occur when sending a request.

TypeError [ERR_UNESCAPED_CHARACTERS]: Request path contains unescaped characters

Fixed by encoding URN before sending request to Model Derivative API.

regards.

petrbroz commented 4 years ago

Thanks @dykarohora for finding and fixing the issue! The PR looks good :+1: I just want to double-check if the URN encoding is really needed. Please see my comment above.

dykarohora commented 4 years ago

Thank you for confirming my pull request.

Attach an excerpt of the manifest when converting a file created with the Japanese version of Revit to SVF.

                    {
                        "guid": "fb389f2c-601c-01e5-b899-893e179f1fed",
                        "type": "resource",
                        "role": "graphics",
                        "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6bWl4cGFjZS1jb252ZXJ0ZXIvMjAxOTExMjAtMTc0NS00Y2E0LTlkYTktZmU2ODliMWQxNjZhLnJ2dA/output/Resource/3D ビュー/{3D} 168067/{3D}.svf",
                        "mime": "application/autodesk-svf"
                    },
                    {
                        "guid": "d047f4b4-cd40-f5b1-ad43-0537cd32ec62",
                        "type": "resource",
                        "role": "thumbnail",
                        "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6bWl4cGFjZS1jb252ZXJ0ZXIvMjAxOTExMjAtMTc0NS00Y2E0LTlkYTktZmU2ODliMWQxNjZhLnJ2dA/output/Resource/3D ビュー/{3D} 168067/{3D}1.png",
                        "resolution": [
                            100,
                            100
                        ],
                        "mime": "image/png",
                        "status": "success"
                    },
                    {
                        "guid": "112bbf3d-91cd-8916-82e2-a3e125249c0e",
                        "type": "resource",
                        "role": "thumbnail",
                        "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6bWl4cGFjZS1jb252ZXJ0ZXIvMjAxOTExMjAtMTc0NS00Y2E0LTlkYTktZmU2ODliMWQxNjZhLnJ2dA/output/Resource/3D ビュー/{3D} 168067/{3D}2.png",
                        "resolution": [
                            200,
                            200
                        ],
                        "mime": "image/png",
                        "status": "success"
                    },
                    {
                        "guid": "ec1ce8d5-39a9-047c-2153-17b8595e542f",
                        "type": "resource",
                        "role": "thumbnail",
                        "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6bWl4cGFjZS1jb252ZXJ0ZXIvMjAxOTExMjAtMTc0NS00Y2E0LTlkYTktZmU2ODliMWQxNjZhLnJ2dA/output/Resource/3D ビュー/{3D} 168067/{3D}4.png",
                        "resolution": [
                            400,
                            400
                        ],
                        "mime": "image/png",
                        "status": "success"
                    }

As you can see, the URN for files uploaded to the bucket is Base64 encoded. However, the SVF path contains multibyte characters. I think this is a problem specific to Revit files.

petrbroz commented 4 years ago

You're right, the URN in that case is not just the Model Derivative URN, but it also includes paths within the SVF which are not encoded. Good catch!