如何将来自Burzum / FileStorage的contentType信息传递给KnpLabs / Gaufrette

CakePHP 3.4 application using the Burzum/FileStorage plugin (which uses KnpLabs/Gaufrette) to manage uploads to AWS S3. Unfortunately, I was running into the issue of MS Office files (docx, xlsx, etc) being detected as ZIP files.

I altered my code to use finfo first and if it detects zip, look at the extension to see if it maybe is an office file. Now I can pass this correct mimetype on to the file_storage table by doing a patchEntity. So far so good.

However, the FileStorage plugin calls KnpLabs/Gaufrette to actually send the file to S3, but it doesn't seem to send along the mimetype/contenttype. So Gaufrette then does its own little finfo trick in the AwsS3 Adapter, writing a metadata field 'Content-Type: application/zip' to the item on S3, causing the Office file to be downloaded as a zip file...

Is there any way to set the correct content type in the options of the AwsS3 adapter?

thanks!

The answer was mentioned here: https://github.com/burzum/cakephp-file-storage/issues/36

It is possible accessing the adapter and setting, for instance, the Content Type using the following code:

$Adapter = \Burzum\FileStorage\Storage\StorageManager::adapter('S3');
$Adapter->getAdapter()->setMetadata($key, array('contentType' => 'whatever'));

Thanks to burzum for pointing this out!