Comments (13)
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.
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.
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.
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:
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.
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.
I'm using S3, but changing it to local doesn't seem to have an effect.
from glide.
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.
Huh. If I change my controller code from
$server->outputImage($request);
to
return $server->getImageResponse($request);
It works.
from glide.
Yes, that works too. I'm using Laravel 5, if that helps at all.
from glide.
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.
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.
Yeah, I'll close it for now, but will probably dig deeper still. Thanks for making me aware of this!
from glide.
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:
from glide.
Related Issues (20)
- Heroku preview app is dead HOT 7
- Problem installing on laravel 6 HOT 2
- How to avoid image-resize attacks from side requests ? HOT 2
- All sample images on the site are broken. HOT 1
- Docs are broken (v1 and v2) HOT 1
- Should filter $params against available manipulations/params HOT 2
- Images load time very slow any suggestions? HOT 3
- Some images converted to webp format has response type "octet-stream" and are empty in browser
- Saving TIFF images
- [ feature ] Save resized files to another directory with different link
- Create custom 404 route? HOT 1
- Repeat watermarks
- Mockery error in League\Glide\ServerTest::testMakeImageFromSource HOT 1
- Could not find the image error in Laravel
- how to get with and height of picture after glide traitement HOT 2
- Image will not manipulate when using crop focus zoom and when resize dimensions are equal to original asset dimensions
- ImagickException: NoDecodeDelegateForThisImageFormat `PNG' HOT 1
- Black border added to images during processing HOT 3
- generate a temporarySignedRoute
- Feature request for base_url option to be regular expression
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from glide.