Daniel-KM / Omeka-S-module-AmazonS3

Module for Omeka S that allows to store files with Amason S3.
Other
6 stars 3 forks source link

Content-Type Metadata Incorrect #1

Open swroberts opened 4 years ago

swroberts commented 4 years ago

When uploading files to s3, the content-type is not correctly read from the filename. As a result, each file is assigned "application/octet-stream", which affects the way files load in the browser, defaulting to downloading.

This thread on AWS Developer Forums (https://forums.aws.amazon.com/thread.jspa?threadID=86700) seems to suggest it can be solved with a slightly different method of passing arguments in the PUT command, but I don't know enough to test it out.

Thanks for all the hard work!

Daniel-KM commented 4 years ago

It is probably fixed in last version for Omeka v3, but can you check?

wragge commented 2 years ago

This still seems to be a problem.

wragge commented 2 years ago

Modifying put to explicitly supply the mime type using the ContentType parameter seems to work (at least for jpgs).

public function put($source, $storagePath): void
    {
        $bucket = $this->getBucketName();
        $mime = mime_content_type($source);
        $args = [
            'Bucket' => $bucket,
            'Key' => $storagePath,
            'SourceFile' => $source,
            'ACL' => 'public-read',
            'ContentType' => $mime,
        ];

I know very little about PHP coding, but I can put this in a merge request if it's helpful.