Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

Can't set contentType when storing file #40

Closed
feenx opened this issue Aug 21, 2018 · 1 comment
Closed

Can't set contentType when storing file #40

feenx opened this issue Aug 21, 2018 · 1 comment

Comments

@feenx
Copy link

feenx commented Aug 21, 2018

Hello, I'm using your GCS driver with my laravel project and I'm attempting to store a file publicly but also set the contentType I've researched and found that I can pass an array metadata with options that should be passed along to GCS but it appears as I'm doing something wrong.

$file->storePubliclyAs($path, $filename = Str::random(40).'.'.$file->guessExtension(), [
    'disk' => app()->environment('local') ? 'local' : 'gcs',
    'metadata' => ['contentType' => $file->getMimeType()],
]);

I've also verified that $file->getMimeType() is text/vcard but always ends up as application/octet-stream in GCS bucket.

I've also tried every variation of contentType Content-Type mimeType mimetype etc inside and outside of metadata array and am at a loss.

Any help would be greatly appreciated!

@feenx
Copy link
Author

feenx commented Aug 23, 2018

It would seem that the UploadedFile classes storePubliclyAs was the culprit. By going back to using Storage::cloud()->putAs($path, $filename, $options); I was able to set the contentType through the metadata just fine. Closing issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant