Closed sushibear closed 2 years ago
This app output Content-Type use nextcloud MimeTypeDetector, please check the file real type at nextcloud data storage place(default at nextcloud-install-path/data/username/files/file-path).
OK .. so I checked the type in the file system, which is image/png.
file -i 6bf2e4728956595bf6dc75bf126.png 6bf2e4728956595bf6dc75bf126.png: image/png; charset=binary
Curl spit out the following as well:
curl -I http://myserver:port/apps/sharingpath/test/Photos/6bf2e4728956595bf6dc75bf126.png HTTP/1.1 200 OK Date: Thu, 29 Apr 2021 08:26:55 GMT Server: Apache/2.4.38 (Debian) X-Content-Type-Options: nosniff X-Download-Options: noopen X-Powered-By: PHP/7.4.15 Set-Cookie: oc5v6wn0om4x=5924f6c003b8fcd5da086b03c57a7c88; path=/; HttpOnly; SameSite=Lax Expires: 0 Cache-Control: must-revalidate, post-check=0, pre-check=0 Pragma: public Set-Cookie: oc_sessionPassphrase=E5ss94e8e2kQVC8hZZZqKmgFLclur%2B8XzpKj0ZwxqJ4XVabdioWQFK7xWZegHaVwcryuN6l0crjyNRRmgkCFxZaHsKoHqI%2BT6sUXt5lUcaFWGzrslLmtKJXrjAYBjif5; path=/; HttpOnly; SameSite=Lax Set-Cookie: oc5v6wn0om4x=1e43f853aafb76b787929355f877f984; path=/; HttpOnly; SameSite=Lax Content-Security-Policy: default-src 'self'; script-src 'self' 'nonce-MThlQjVGTDYzeTJocFp3SHFtZDJMZWdZNFUwaHpKd2RBck5Bd0lBS3hHUT06bllIUnBocWpzSHZId2NoOThCUVJIOThwdEh3WmhkcC9UZkVxaExkRWxBbz0='; style-src 'self' 'unsafe-inline'; frame-src *; img-src * data: blob:; font-src 'self' data:; media-src *; connect-src *; object-src 'none'; base-uri 'self'; Set-Cookie: nc_sameSiteCookielax=true; path=/; httponly;expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=lax Set-Cookie: nc_sameSiteCookiestrict=true; path=/; httponly;expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=strict Content-Transfer-Encoding: binary Content-Length: 2180227 Content-Type: image/png
Safari, Firefox and Postman are properly show the image in the browser, only Chrome wants to download the shared files.
Chrome Warning:
Resource interpreted as Document but transferred with MIME type application/octet-stream
Chrome Headers:
HTTP/1.1 200 OK Date: Thu, 29 Apr 2021 08:30:30 GMT Server: Apache/2.4.38 (Debian) X-Content-Type-Options: nosniff X-Download-Options: noopen X-Powered-By: PHP/7.4.15 Expires: 0 Cache-Control: must-revalidate, post-check=0, pre-check=0 Pragma: public Content-Security-Policy: default-src 'self'; script-src 'self' 'nonce-UStSODBTZ0t4RnViWTU3dTFwZnEvVXdxbGwvdmp2b0FBRnpkTERhb3UzQT06Q1owZTVFOHpzQ24wSzdHTGhQYUlySHhJOFRlbDlLczBVaSs4ZlhUdDZDaz0='; style-src 'self' 'unsafe-inline'; frame-src *; img-src * data: blob:; font-src 'self' data:; media-src *; connect-src *; object-src 'none'; base-uri 'self'; Content-Transfer-Encoding: binary Content-Length: 0 Keep-Alive: timeout=5, max=100 Connection: Keep-Alive Content-Type: text/plain access-control-allow-origin: * access-control-allow-methods: GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS access-control-allow-headers: * access-control-expose-headers: *
Do you have any idea why Chrome gets the wrong mime type from the cloud when I try to access the file?
ps: Content-Length: 0
looks suspicious to me. Even if I get a Status Code: 200 OK
when accessing the file, the content length seems to be always 0. Maybe it's not a mime type issue but something else?
I think I got something... even though this is just a hint of what's going on here...
When I try to access a file thru sharing path in Chrome, I see the following error in the Nextcloud log:
{"reqId":"vElWnCbJglNVgzd026n0","level":3,"time":"2021-04-29T09:51:56+00:00","remoteAddr":"10.105.29.65","user":"admin","app":"PHP","method":"GET","url":"/apps/sharingpath/test/Photos/6bf2e4728956595bf6dc75bf126.png","message":{"Exception":"Error","Message":"fopen(/var/www/html/data/admin/files/Photos/6bf2e4728956595bf6dc75bf126.png): failed to open stream: No such file or directory at /var/www/html/lib/private/Files/Storage/Local.php#355","Code":0,"Trace":[{"function":"onError","class":"OC\\Log\\ErrorHandler","type":"::","args":[2,"fopen(/var/www/html/data/admin/files/Photos/6bf2e4728956595bf6dc75bf126.png): failed to open stream: No such file or directory","/var/www/html/lib/private/Files/Storage/Local.php",355,{"path":"files/Photos/6bf2e4728956595bf6dc75bf126.png","mode":"r"}]},{"file":"/var/www/html/lib/private/Files/Storage/Local.php","line":355,"function":"fopen","args":["/var/www/html/data/admin/files/Photos/6bf2e4728956595bf6dc75bf126.png","r"]},{"file":"/var/www/html/lib/private/Files/Storage/Wrapper/Wrapper.php","line":300,"function":"fopen","class":"OC\\Files\\Storage\\Local","type":"->","args":["files/Photos/6bf2e4728956595bf6dc75bf126.png","r"]},{"file":"/var/www/html/lib/private/Files/View.php","line":1165,"function":"fopen","class":"OC\\Files\\Storage\\Wrapper\\Wrapper","type":"->","args":["files/Photos/6bf2e4728956595bf6dc75bf126.png","r"]},{"file":"/var/www/html/lib/private/Files/View.php","line":1001,"function":"basicOperation","class":"OC\\Files\\View","type":"->","args":["fopen","/Photos/6bf2e4728956595bf6dc75bf126.png",["read"],"r"]},{"file":"/var/www/html/lib/private/Files/View.php","line":425,"function":"fopen","class":"OC\\Files\\View","type":"->","args":["/Photos/6bf2e4728956595bf6dc75bf126.png","r"]},{"file":"/var/www/html/custom_apps/sharingpath/lib/Controller/PathController.php","line":149,"function":"readfile","class":"OC\\Files\\View","type":"->","args":["/Photos/6bf2e4728956595bf6dc75bf126.png"]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":169,"function":"handle","class":"OCA\\SharingPath\\Controller\\PathController","type":"->","args":["test","/Photos/6bf2e4728956595bf6dc75bf126.png"]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":100,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\SharingPath\\Controller\\PathController"},"handle"]},{"file":"/var/www/html/lib/private/AppFramework/App.php","line":152,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\SharingPath\\Controller\\PathController"},"handle"]},{"file":"/var/www/html/lib/private/Route/Router.php","line":309,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["PathController","handle",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"uid":"test","path":"Photos/6bf2e4728956595bf6dc75bf126.png","_route":"sharingpath.Path.handle"}]},{"file":"/var/www/html/lib/base.php","line":1008,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/apps/sharingpath/test/Photos/6bf2e4728956595bf6dc75bf126.png"]},{"file":"/var/www/html/index.php","line":37,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/html/lib/private/Log/ErrorHandler.php","Line":91,"CustomMessage":"--"},"userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36","version":"20.0.6.1","id":"608a81bd5bf47"}
formatted:
[PHP] Error: Error: fopen(/var/www/html/data/admin/files/Photos/6bf2e4728956595bf6dc75bf126.png): failed to open stream: No such file or directory at /var/www/html/lib/private/Files/Storage/Local.php#355 at <<closure>>
0. <<closure>>
OC\Log\ErrorHandler::onError(2, "fopen(/var/www/ ... y", "/var/www/html/l ... p", 355, {path: "files/Ph ... "})
1. /var/www/html/lib/private/Files/Storage/Local.php line 355
fopen("/var/www/html/d ... g", "r")
2. /var/www/html/lib/private/Files/Storage/Wrapper/Wrapper.php line 300
OC\Files\Storage\Local->fopen("files/Photos/6b ... g", "r")
3. /var/www/html/lib/private/Files/View.php line 1165
OC\Files\Storage\Wrapper\Wrapper->fopen("files/Photos/6b ... g", "r")
4. /var/www/html/lib/private/Files/View.php line 1001
OC\Files\View->basicOperation("fopen", "/Photos/6bf2e4728956595bf6dc75bf126.png", ["read"], "r")
5. /var/www/html/lib/private/Files/View.php line 425
OC\Files\View->fopen("/Photos/6bf2e4728956595bf6dc75bf126.png", "r")
6. /var/www/html/custom_apps/sharingpath/lib/Controller/PathController.php line 149
OC\Files\View->readfile("/Photos/6bf2e4728956595bf6dc75bf126.png")
7. /var/www/html/lib/private/AppFramework/Http/Dispatcher.php line 169
OCA\SharingPath\Controller\PathController->handle("test", "/Photos/6bf2e4728956595bf6dc75bf126.png")
8. /var/www/html/lib/private/AppFramework/Http/Dispatcher.php line 100
OC\AppFramework\Http\Dispatcher->executeController(OCA\SharingPath\ ... {}, "handle")
9. /var/www/html/lib/private/AppFramework/App.php line 152
OC\AppFramework\Http\Dispatcher->dispatch(OCA\SharingPath\ ... {}, "handle")
10. /var/www/html/lib/private/Route/Router.php line 309
OC\AppFramework\App::main("PathController", "handle", OC\AppFramework\ ... {}, {uid: "test",pat ... "})
11. /var/www/html/lib/base.php line 1008
OC\Route\Router->match("/apps/sharingpa ... g")
12. /var/www/html/index.php line 37
OC::handleRequest()
GET /apps/sharingpath/test/Photos/6bf2e4728956595bf6dc75bf126.png
from MY_IP by admin at 2021-04-29T09:51:56+00:00
Looks like even if I try to get the file from this path:
/apps/sharingpath/test/Photos/6bf2e4728956595bf6dc75bf126.png
it ends up with this path instead:
/apps/sharingpath/admin/Photos/6bf2e4728956595bf6dc75bf126.png
What do you think could cause this that it only happens in Chrome and nowhere else?
Maybe related to https://github.com/rookie0/nextcloud-sharing-path/issues/23#issuecomment-679144870, this app(or nextcloud) got wrong user.
I will follow up.
Hey .. any news on this issue?
Really does look like it might be releated to #23
This is just a blind guess and I am not sure if it by any chance could be the problem of this plugin, but is there a possibility that the MIME types set in Nextcloud and the MIME types set in Apache are completely ignored by the browser when accessing files thru a shared path?
I have problems for instance loading JPGs, PNGs or .js files from a share and get different behaviour loading these file types in different browsers.
Any ideas?
Could be related to: https://github.com/rookie0/nextcloud-sharing-path/issues/21#issue-628119373