flownative / flow-aws-s3

Amazon S3 adaptor for Neos and Flow
MIT License
18 stars 33 forks source link

Wrong content type when resource:copy to Minio #56

Open christophlehmann opened 2 years ago

christophlehmann commented 2 years ago

Using Minio and evaluating the one-bucket setup i face that copied resources always get the content type application/octet-stream.

In https://github.com/flownative/flow-aws-s3/blob/master/Classes/S3Storage.php#L225 getMediaType() always returns application/octet-stream because $temporaryPathAndFilename does not have the original filename containing the fileExtension which is used in getMediaType() to detect the content-type by filename.

What works is using mime_content_type($temporaryTargetPathAndFilename), but during the fact, that the correct content type is already in the neos_flow_resourcemanagement_persistentresource table, it's rather a workaround.

kdambekalns commented 1 year ago

Well, you say

the correct content type is already in the neos_flow_resourcemanagement_persistentresource table

Then why is the resource imported (again) using importResourceFromContent(), which by defintiion only sees the content, but never a filename?

Or am I misunderstanding something here?

christophlehmann commented 1 year ago

Hey, this is about copying resources from local persistent storage to S3 storage. In resource:copy \Flownative\Aws\S3\S3Storage::importResource() is called, but it sadly gets no PersistentResource object, which could be used to use put original meta data from the database record into S3. So, the patch is just a workaround until importResource() can receive a PersistentResource object.