Support the ongoing development of Laravel.io →
posted 9 years ago
Requests

Hi,

I have the following problem: if I redirect to a signed s3 url from the php aws sdk v2, the download works fine. If I redirect to a signed s3 url from the php aws sdk v3, the browsers says that there are duplicate "location" response headers.

Is anyone having the same issue? Any workarounds?

I suppose the redirect is sending some headers to the client that are also are sent by the s3 response.

Last updated 3 years ago.
0
Solution

Solved:

$request = $client->createPresignedRequest(...);
// uri is a guzzle uri object
$uri = $request->getUri();
// cast $uri as string
redirect((string)$uri);

You have to explicitly cast the $uri as string. Otherwise you get a Location header for each property of the $uri object, the __toString() method doesn't get called.

Last updated 9 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

thiver thiver Joined 11 Dec 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.