X-Ryl669 / grav-plugin-viewer3d

GNU Affero General Public License v3.0
2 stars 1 forks source link

“Fetch failed” error #8

Open BlueSoap opened 2 years ago

BlueSoap commented 2 years ago

I’m having an error when trying to save a page when the page’s folder contains a .obj file. The red popup says:

Fetch Failed: can't convert undefined to object

56299/fetchMedia/<@http://localhost/harmonie/grav-admin/user/plugins/admin/themes/grav/js/admin.min.js?8ef3c2ad3e:4325:16 56299/request/<@http://localhost/harmonie/grav-admin/user/plugins/admin/themes/grav/js/admin.min.js?8ef3c2ad3e:890:12

I'm unsure if this is due to the .obj file itself (I thought maybe this could be related to a mime type issue, as I'm having some trouble with that?), or an entirely separate configuration issue with my server.

Cheers,

X-Ryl669 commented 2 years ago

Have you declared the MIME type for OBJ files (like I've documented here) in grav's config ?

Should be model/obj but make sure that's what your browser is reporting demo here

BlueSoap commented 2 years ago

I did! I tried others mime type declarations, too (for testing sake!), but to no effect. It's tricky. The test page you suggested returns type:unknown (for 3 different .obj models from various sources). This other test page returns "text/plain" for the same models.

BlueSoap commented 2 years ago

I'm using Firefox (101.0.1) by the way.

X-Ryl669 commented 2 years ago

It works for me (just tried with your model.zip file). I've added both model/obj and model/mtl and was able to upload. You might need to increase the php's upload_max_filesize (in your php.ini) and your webserver (nginx: that's client_max_body_size).

BlueSoap commented 2 years ago

Thank you for your instructions. I reinstalled the plugin and edited the php.ini and restarted my local server, but I do still have that message box.

BlueSoap commented 2 years ago

There seems to be some sort of conflict in the browser's response though—here on firefox, test pages display "text/plain" or "type:unknown" for tested .obj files, and Grav's admin displays the same error message regardless of the type specified in the Media tab.

Also, on trying to upload .obj files through the page's admin, it will reply with "The mime type does not match to file extension," regardless of the Media tab config.

X-Ryl669 commented 2 years ago

This is what you have? image

If yes, please capture the error (in the developer's console, network tab, locate the upload request (it's a POST) and right click "Copy / As CURL", then run the request in a terminal to capture the complete communication.

BlueSoap commented 2 years ago

Yes, this is it. Here's what it says in the terminal:

> curl 'http://localhost/website/grav-admin/admin/pages/section/test.json/task:listmedia' -X POST 
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Firefox/102.0' 
-H 'Accept: application/json' 
-H 'Accept-Language: en-GB,en;q=0.7,fr;q=0.3' 
-H 'Accept-Encoding: gzip, deflate, br' 
-H 'Referer: http://localhost/website/grav-admin/admin/pages/section/test' 
-H 'Content-Type: multipart/form-data; boundary=---------------------------25869558015086161081329945515' -H 'Origin: http://localhost' 
-H 'Connection: keep-alive' 
-H 'Cookie: grav-site-b1c1bc1=redacted; grav-site-b1c1bc1-admin=redacted; grav-admin-flexpages=eyJyb3V0ZSI6Ii9oYXJtb2RleCIsImZpbHRlcnMiOnt9fQ%3D%3D; grav-admin-sidebar=true; grav-tabs-state={%22tab-flex-pages-e838602f51515c83bca06a8ae758ce52%22:%22data.content%22%2C%22tab-flex-pages-raw-8f0a83a672754f7823714134334b1de8%22:%22data.content%22%2C%22tab--f0e041eed24f87f2b6b02fd6924d0a08%22:%22data.accounts%22}; grav-admin-pagemedia={%22width%22:%22130%22%2C%22collapsed%22:false}' 
-H 'Sec-Fetch-Dest: empty' 
-H 'Sec-Fetch-Mode: cors' 
-H 'Sec-Fetch-Site: same-origin' 
--data-binary $'-----------------------------25869558015086161081329945515\r\nContent-Disposition: form-data; name="admin-nonce"\r\n\r\n3c7f8338d3ff1b312efd86b138ecb71f\r\n-----------------------------25869558015086161081329945515\r\nContent-Disposition: form-data; name="uri"\r\n\r\n\r\n-----------------------------25869558015086161081329945515\r\nContent-Disposition: form-data; name="order"\r\n\r\nportrait.jpg,Binary_0.jpeg\r\n-----------------------------25869558015086161081329945515--\r\n
X-Ryl669 commented 2 years ago

Seems like you've captured the upload of the picture (this should work, right ?) Can you capture the upload of the .obj or .mtl file instead ?

X-Ryl669 commented 2 years ago

I've deleted your post, because it contained personal information. It seems like you're captured the download of the list of media files (including the MTL file), not the upload. I need to think about this a bit more.

BlueSoap commented 2 years ago

Thank you!