thephpleague / flysystem

Abstraction for local and remote filesystems
https://flysystem.thephpleague.com
MIT License
13.23k stars 825 forks source link

AWS S3 Adapter: retrieve mime type from file content #1781

Open miloslavkostir opened 1 month ago

miloslavkostir commented 1 month ago

Feature Request

Q A
Adapter Name AwsS3V3Adapter

Some services don't support Content-Type as a request parameter for PutObject e.g. Dell PowerScale OneFS see OneFS S3 API doc Table 21. OneFS S3 PutObject API request parameters On the other hand, some developers may prefer retrieving mime type from file content in the function AwsS3V3Adapter::mimeType() instead of getting it from HeadObject

What about creating (an optional) feature for retrieving content type from file content? Something like this:

$mimetype = $this->mimeTypeDetector->detectMimeTypeFromBuffer(fread($this->readStream($path), 1024));

Ideally I could the function enable/disable in the options.

miloslavkostir commented 1 month ago

Like this https://github.com/miloslavkostir/flysystem/commit/229437159c4b0b0d91f849a83e1e8fcd304398de