1up-lab/OneupUploaderBundle

GaufretteFile getMimeType using basename instead of the full key?

jandom opened this issue · 1 comments

Question

Thank you for maintaining and supporting this awesome package! This is a very simple question, in Gaufrette file there is a handy getMimeType method, for AWS S3 specifically it has this behavior

        } elseif ($this->filesystem->getAdapter() instanceof AwsS3 && !$this->mimeType) {
            $metadata = $this->filesystem->getAdapter()->getMetadata($this->getBasename());
            if (isset($metadata['ContentType'])) {
                $this->mimeType = $metadata['ContentType'];
            }
        }

Here the getMetadata needs a full S3 object key, eg "2020/09/30/test-5f7455033c902.pdf" rather than just a basename. The way getBasenname is defined in GaufretteFile, I think, it'll truncate the key

    public function getBasename(): string
    {
        return pathinfo($this->getKey(), PATHINFO_BASENAME);
    }

Is that on purpose? Shouldn't the line be

            $metadata = $this->filesystem->getAdapter()->getMetadata($this->getKey());
Q A
Version current master
stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.