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

Cannot view s3 uploads /raw, thumbnails fine and local storage fine #543

Open
JustaPeriod opened this issue Jul 31, 2023 · 4 comments
Open

Comments

@JustaPeriod
Copy link

JustaPeriod commented Jul 31, 2023

System Info

  • PHP Version: PHP 8.1.2-1ubuntu2.13
  • XBackBone Version: 3.6.3
  • Webserver: Apache/2.4.52 (Ubuntu)
  • Database backend: MariaDB

Describe the bug
Files uploaded to s3 buckets are not viewable raw. The files upload just fine, and are viewable and downloadable from the bucket or via a different tool, but do not load on xbackbone with /raw. In fact, it seems there is literally no header received when viewing files /raw. I get a completely blank page with no information to inspect in my browser.

Thumbnails display fine though. If I add ?width=500 or similar after /raw the images load fine. And local storage works absolutely fine, files display correctly.

I cannot download other files such as zips or videos. Any file you try to download saves as an empty file with 0 bytes downloaded. Seems identical to what someone else faced in #311

I have tried three different S3 compatible buckets with the exact same results: IDrive E2, Fybe, and Wasabi.

To Reproduce
Upload file via website or sharex and visit page.

Expected behavior
The files appear neither on the normal link or the /raw link.
If I take the raw link and add ?width=1000 to the end or similar, it then displays fine.

Screenshots
You can see the image upload is broken here:
image
But the thumbnail works just fine here:
image

Logs
XBackBone Log viewing images (no error, but no image loads):

[2023-07-31 13:50:04] app.INFO: User period uploaded new media. ["21"] []
[2023-07-31 14:19:25] app.INFO: User period uploaded new media. ["22"] []

Here's the XBackBone Log after trying to watch a video (url replaced). Probably because it's trying to load an empty stream?

[2023-07-31 15:02:51] app.ERROR: Slim Application Error
Type: RuntimeException
Code: 0
Message: Could not seek in stream.
File: /var/www/example.com/html/vendor/slim/psr7/src/Stream.php
Line: 311
Trace: #0 /var/www/example.com/html/app/Controllers/MediaController.php(498): Slim\Psr7\Stream->seek()
#1 /var/www/example.com/html/app/Controllers/MediaController.php(411): App\Controllers\MediaController->handlePartialRequest()
#2 /var/www/example.com/html/app/Controllers/MediaController.php(163): App\Controllers\MediaController->streamMedia()
#3 [internal function]: App\Controllers\MediaController->getRaw()
#4 /var/www/example.com/html/vendor/php-di/invoker/src/Invoker.php(74): call_user_func_array()
#5 /var/www/example.com/html/vendor/php-di/slim-bridge/src/ControllerInvoker.php(47): Invoker\Invoker->call()
#6 /var/www/example.com/html/vendor/slim/slim/Slim/Routing/Route.php(384): DI\Bridge\Slim\ControllerInvoker->__invoke()
#7 /var/www/example.com/html/vendor/slim/slim/Slim/MiddlewareDispatcher.php(81): Slim\Routing\Route->handle()
#8 /var/www/example.com/html/vendor/slim/slim/Slim/MiddlewareDispatcher.php(81): Slim\MiddlewareDispatcher->handle()
#9 /var/www/example.com/html/vendor/slim/slim/Slim/Routing/Route.php(341): Slim\MiddlewareDispatcher->handle()
#10 /var/www/example.com/html/vendor/slim/slim/Slim/Routing/RouteRunner.php(84): Slim\Routing\Route->run()
#11 /var/www/example.com/html/app/Middleware/InjectMiddleware.php(21): Slim\Routing\RouteRunner->handle()
#12 /var/www/example.com/html/vendor/slim/slim/Slim/MiddlewareDispatcher.php(209): App\Middleware\InjectMiddleware->__invoke()
#13 /var/www/example.com/html/app/Middleware/LangMiddleware.php(25): Psr\Http\Server\RequestHandlerInterface@anonymous->handle()
#14 /var/www/example.com/html/vendor/slim/slim/Slim/MiddlewareDispatcher.php(209): App\Middleware\LangMiddleware->__invoke()
#15 /var/www/example.com/html/app/Middleware/RememberMiddleware.php(39): Psr\Http\Server\RequestHandlerInterface@anonymous->handle()
#16 /var/www/example.com/html/vendor/slim/slim/Slim/MiddlewareDispatcher.php(209): App\Middleware\RememberMiddleware->__invoke()
#17 /var/www/example.com/html/bootstrap/app.php(105): Psr\Http\Server\RequestHandlerInterface@anonymous->handle()
#18 /var/www/example.com/html/vendor/slim/slim/Slim/MiddlewareDispatcher.php(313): Closure->{closure}()
#19 /var/www/example.com/html/vendor/slim/slim/Slim/Middleware/RoutingMiddleware.php(59): Psr\Http\Server\RequestHandlerInterface@anonymous->handle()
#20 /var/www/example.com/html/vendor/slim/slim/Slim/MiddlewareDispatcher.php(147): Slim\Middleware\RoutingMiddleware->process()
#21 /var/www/example.com/html/vendor/slim/slim/Slim/Middleware/ErrorMiddleware.php(107): Psr\Http\Server\RequestHandlerInterface@anonymous->handle()
#22 /var/www/example.com/html/vendor/slim/slim/Slim/MiddlewareDispatcher.php(147): Slim\Middleware\ErrorMiddleware->process()
#23 /var/www/example.com/html/vendor/slim/slim/Slim/MiddlewareDispatcher.php(81): Psr\Http\Server\RequestHandlerInterface@anonymous->handle()
#24 /var/www/example.com/html/vendor/slim/slim/Slim/App.php(215): Slim\MiddlewareDispatcher->handle()
#25 /var/www/example.com/html/vendor/slim/slim/Slim/App.php(199): Slim\App->handle()
#26 /var/www/example.com/html/index.php(11): Slim\App->run()
#27 {main} [] []

No apache error log.

Apache Access Log for the image:

IP - - [31/Jul/2023:14:36:27 +0000] "HEAD /xahO4/zERUJOfO85.png HTTP/1.1" 200 639 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 OPR/100.0.0.0"
IP - - [31/Jul/2023:14:36:27 +0000] "GET /xahO4/zERUJOfO85.png HTTP/1.1" 200 12561 "https://example.com/home" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 OPR/100.0.0.0"
IP - - [31/Jul/2023:14:36:27 +0000] "GET /xahO4/zERUJOfO85.png HTTP/1.1" 200 8286 "https://example.com/home" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 OPR/100.0.0.0"
IP - - [31/Jul/2023:14:36:28 +0000] "GET /xahO4/zERUJOfO85.png/raw HTTP/1.1" 200 74355 "https://example.com/xahO4/zERUJOfO85.png" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 OPR/100.0.0.0"
@JustaPeriod
Copy link
Author

I found that trying to view it in firefox actually gave me something at least, unlike chrome.

<html><head><meta name="viewport" content="width=device-width; height=device-height;"><link rel="stylesheet" href="resource://content-accessible/ImageDocument.css"><link rel="stylesheet" href="resource://content-accessible/TopLevelImageDocument.css"><title>raw ( Image)</title></head><body><img src="https://example.com/xahO4/zERUJOfO85.png/raw" alt="The image “https://example.com/xahO4/zERUJOfO85.png/raw” cannot be displayed because it contains errors."></body></html>

If I add ?width=500 so it actually loads, here's what I get:

<html><head><meta name="viewport" content="width=device-width; height=device-height;"><link rel="stylesheet" href="resource://content-accessible/ImageDocument.css"><link rel="stylesheet" href="resource://content-accessible/TopLevelImageDocument.css"><title>scaled-2023-07-31_09-19-23.png (PNG Image, 500&nbsp;×&nbsp;217 pixels)</title></head><body><img src="https://example.com/xahO4/zERUJOfO85.png/raw?width=500" alt="https://example.com/xahO4/zERUJOfO85.png/raw?width=500" class="transparent"></body></html>

@JustaPeriod JustaPeriod changed the title Cannot view uploads /raw, thumbnails fine Cannot view s3 uploads /raw, thumbnails fine and local storage fine Aug 2, 2023
@kymppi
Copy link

kymppi commented Sep 16, 2023

I'm experiencing the same problem with S3 and SQLite. Kinda weird, but I don't get any errors in the logs.

@kymppi
Copy link

kymppi commented Sep 16, 2023

Actually. When reading the nginx logs I saw something:

2023/09/16 16:51:10 [error] 267#267: *1 upstream sent invalid "Content-Length" header: "Content-Length: " while reading response header from upstream, client: 10.42.0.11, server: _, request: "GET /HAbU8/cUxAFelu41.png/raw HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "<domain>", referrer: "https://<domain>/HAbU8/cUxAFelu41.png"
2023/09/16 16:51:24 [error] 267#267: *1 upstream sent invalid "Content-Length" header: "Content-Length: " while reading response header from upstream, client: 10.42.0.11, server: _, request: "GET /HAbU8/cUxAFelu41.png/raw HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "<domain>", referrer: "https://<domain>/HAbU8/cUxAFelu41.png"
2023/09/16 16:52:54 [error] 270#270: *10 upstream sent invalid "Content-Length" header: "Content-Length: " while reading response header from upstream, client: 10.42.0.11, server: _, request: "GET /HAbU8/cUxAFelu41.png/raw HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "<domain>", referrer: "https://<domain>/HAbU8/cUxAFelu41.png"

@WhyAydan
Copy link

Having the same issue, is there any update on this?

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

No branches or pull requests

3 participants