Code Monkey home page Code Monkey logo

Comments (13)

reinink avatar reinink commented on September 13, 2024 3

That does make sense, since Laravel knows how to process a HttpFoundation Response object. Laravel actually uses HttpFoundation for it's request and response objects. Still, it doesn't entirely explain why just doing $glide->outputImage($request); doesn't work.

I'd be curious if this would work:

$glide->outputImage($request);
exit;

from glide.

reinink avatar reinink commented on September 13, 2024 1

Hmm, now I'm totally confused. Basically that line generates the response, and sends it right away. This allows you to do this:

$glide->outputImage($request);

However, if you actually wanted the image response object, you could do this:

$response = $glide->getImageResponse($request);
$response->send();

If you were to change the Glide code to return ResponseFactory::create($this->cache, $request, $this->getCachePath($request))->send();, it would essentially do the same thing it does now (output the response), however the send() method returns and instance of the response object, so that is what you'll get back instead of an instance of the request object. You can see that here.

from glide.

nicolas-t avatar nicolas-t commented on September 13, 2024 1

Yup, for me too cache is stored as application/octet-stream

maybe because it has no extension ?

images are served as application/octet-stream too, so i have to force header like this :

$response = $server->getImageResponse($path, []);
$response->headers->set('content-type', 'image/jpeg');
return $response;

from glide.

ametad avatar ametad commented on September 13, 2024 1

Hi, it seems that I experience this same issue, but I'm storing my cache in Google storage bucket. When I try to store locally, it works fine. When trying to store in google storage, it got stored as an object, as shown below: screen shot 2017-01-06 at 2 46 44 am

@hanishassim

Thank you! I've searched for the whole wrong kind of reasons why I got the application/octet-stream header instead of the image/* header... And fortunately I saw your comment all of a sudden.. Finally I can fix my problem, so thank you.

from glide.

reinink avatar reinink commented on September 13, 2024

Thanks for posting this Jason. Just so you know, this is how Glide currently sets the Content-Type:

$response->headers->set('Content-Type', $this->cache->getMimetype($this->path));

Full context here.

So it would seem that the Flysystem getMimetype() method isn't returning the correct value. And how that is resolved will be different for each Flysystem adapter you use.

Where are you storing your cache in production? S3? Locally? Other?

from glide.

jasonvarga avatar jasonvarga commented on September 13, 2024

I'm using S3, but changing it to local doesn't seem to have an effect.

from glide.

jasonvarga avatar jasonvarga commented on September 13, 2024

Tinkering around in the code, in this file:

https://github.com/thephpleague/glide/blob/master/src/Server.php#L254-L256

If I return the ResponseFactory line instead of $request, it works. I don't know what sort of repercussions this would have...

from glide.

jasonvarga avatar jasonvarga commented on September 13, 2024

Huh. If I change my controller code from

$server->outputImage($request);

to

return $server->getImageResponse($request);

It works.

from glide.

jasonvarga avatar jasonvarga commented on September 13, 2024

Yes, that works too. I'm using Laravel 5, if that helps at all.

from glide.

reinink avatar reinink commented on September 13, 2024

I think what is happening is that you're outputting the image using Glide. However, since you are not returning anything from your controller, Laravel considers it a blank, plain-text page, and is probably adding headers for that. Now that still doesn't make total sense for me, because you cannot set headers after already outputting content, unless Laravel is using output buffering, which is very well could be.

Still totally puzzled why it works locally though.

from glide.

jasonvarga avatar jasonvarga commented on September 13, 2024

You and me both. Returning the image response fixed my problem, so you can consider this issue closed from my perspective.

Feel free to keep it open if you need to dig deeper. Let me know if I can be of any more help.

from glide.

reinink avatar reinink commented on September 13, 2024

Yeah, I'll close it for now, but will probably dig deeper still. Thanks for making me aware of this!

from glide.

hanishassim avatar hanishassim commented on September 13, 2024

Hi, it seems that I experience this same issue, but I'm storing my cache in Google storage bucket. When I try to store locally, it works fine. When trying to store in google storage, it got stored as an object, as shown below:
screen shot 2017-01-06 at 2 46 44 am

from glide.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.