doutenglou6588 2018-08-17 13:26 采纳率: 0%
浏览 64
已采纳

如何将来自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!

  • 写回答

1条回答 默认 最新

  • douzhi4991 2018-08-24 09:06
    关注

    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!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧