thephpleague / glide

Wonderfully easy on-demand image manipulation library with an HTTP based API.
http://glide.thephpleague.com
MIT License
2.55k stars 198 forks source link

Glide Image Manipulation Content Length Mismatch Glitch on Laravel 6 #265

Closed PhoenixPeca closed 5 years ago

PhoenixPeca commented 5 years ago

Hi,

I have just upgraded my framework to the new Laravel 6.0.0. However, I'm experiencing a random glitch/bug/error with Glide as shown in the screenshot: Screenshot

Glide seems to work fine (most of the time).. But whenever, I fetch the image without setting any manipulation parameters through the the ImageController, I get a partial view of the image and an error in chrome's console: net::ERR_CONTENT_LENGTH_MISMATCH 200 (OK). But this happens about every 3 out of 5 requests, randomly... Behaviour seems inconsistent because sometimes I get the full image, but sometimes I also get only part of the image as shown in the screenshot.

I reverted to the last laravel 5 release, and I haven't noticed this particular problem.

Regards, Phoenix Eve Aspacio

PhoenixPeca commented 5 years ago

ImageController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Contracts\Filesystem\Filesystem;
use League\Glide\ServerFactory;
use League\Glide\Signatures\SignatureFactory;
use League\Glide\Signatures\SignatureException;
use League\Glide\Responses\LaravelResponseFactory;
use League\Glide\Filesystem\FileNotFoundException;

class ImageController extends Controller
{
    public function show(Request $request, Filesystem $filesystem, $path)
    {
        $local_resource = 'public/resources/';

        try {
            SignatureFactory::create(env('APP_KEY'))->validateRequest(
                'resources/' . $path,
                $request->all()
            );

            $fs_driver = $filesystem->getDriver();

            $server = ServerFactory::create([
                'response' => new LaravelResponseFactory(),
                'source_path_prefix' => $local_resource,
                'source' => $fs_driver,
                'cache_path_prefix' => $local_resource . '.cache/',
                'cache' => $fs_driver,
                'driver' => 'gd'
            ]);

            return $server->getImageResponse($path, $request->all());
        } catch (SignatureException $e) {
            abort(403);
        } catch (FileNotFoundException $e) {
            abort(404);
        }
    }
}

Could this be caused by an outdated dependency?

PhoenixPeca commented 5 years ago

Hi,

Sorry for bothering... Just solved my problem. https://serverfault.com/questions/235154/permission-denied-while-reading-upstream

It wasn't a laravel/glide issue afterall..

Eitherway, this is a very nice package.. I was working on a project and was using gumlet (https://www.gumlet.com/) then I found this and settled..

Cheers to the developer!

reinink commented 5 years ago

👍