Skip to content

Unable to retrieve the mime_type for file with Storage::download #41960

Closed
@0xVavaldi

Description

  • Laravel Version: 9.8.1
  • PHP Version: 8.1.3
  • league/flysystem 3.0.16

Description:

$headers["Content-Type"] = "text/plain";
$headers["Content-Length"] = $file_size;
$headers["Accept-Ranges"] = "bytes";
$headers["Content-Disposition"] = "attachment; filename={$id}.left";
$headers["Content-Range"] = "bytes " . 0 . "-" . ($file_size) . "/" . $file_size;
Storage::disk("localdisk")->download($id.".found", $headers);

Results in the following error:

local.ERROR: Unable to retrieve the mime_type for file at location: 737.found.  {"exception":"[object] (League\\Flysystem\\UnableToRetrieveMetadata(code: 0): Unable to retrieve the mime_type for file at location: 737.found.  at /var/www/hostname/vendor/league/flysystem/src/UnableToRetrieveMetadata.php:49)

I believe this is caused by me having a non-standard extension, which is fine since I provided the content-type in the headers explicitly. But instead I'm getting errors now with my recent upgrade from laravel 8 to laravel 9. Any way to make this work?

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions