i have the same issue.
Oct 22, 2017
6
Level 2
unable to test filesystem temporaryUrl
- Laravel Version: 5.5.11
- PHP Version: 7.1
- Database Driver & Version: MySQL
Description:
I have written some test to verify that a file exists on s3 and download when tried to test Storage::disk('s3')->temporaryUrl($url, $urlExpires); It gives 500 error with this msg but the code works when test by the browser.
This driver does not support creating temporary URLs
Steps To Reproduce:
Test
Storage::fake('s3');
// Create attachment
$attachment = Attachment::create([
'name' => 'PDF Doc',
'url' => Storage::disk('s3')->put(
'attachments',
UploadedFile::fake()->create('document.pdf'),
1000)
]);
Storage::disk('s3')->assertExists($attachment->url);
...
$this->actingAs($user)
->get(route('attachments.download', $attachment->id))
->assertRedirect()
// it fails with with 500
Implementaion
$url = Attachment::find($id)->url;
if( Storage::disk('s3')->exists($url) ) {
// link expiration time
$urlExpires = Carbon::now()->addMinutes(10);
try {
$tempUrl = Storage::disk('s3')->temporaryUrl($url, $urlExpires);
return redirect($tempUrl);
} catch ( \Exception $e ) {
// Unable to test temporaryUrl, its giving driver dont support it issue.
return response($e->getMessage());
}
}
One more question?
Is there any way to customize the URL generated by temporaryUrl(), problem is downloaded filename is some random string rlbPsVUhqubaXGoEQk96wjPXfQTqurJvNgVjRMZ8.doc which is not very good, I like to customize the name of file to something like project-details.doc etc ?
Please or to participate in this conversation.