How can I change mime type for uploaded files on Amazon S3. I have tried with http://docs.amazonwebservices.com/AWSSDKforPHP/latest/#m=AmazonS3/change_content_type but its not working.
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
You could try this:
The core Amazon S3 service makes no attempt to preserve the ACLs or content-types during a copy-in-place (i.e., replace) operation.
I know that the AmazonS3::change_content_type() method is simply a wrapper around the copy_object() method. If you look at the implementation, you'll see that the PHP SDK makes an attempt to lookup the current ACL and content-type before executing the copy-in-place operation to workaround this problem in the core S3 service.
If it isn't working for you, have you posted this as a bug to the AWS PHP forum? It appears that the developer of the SDK is pretty responsive to addressing bugs that get reported there.
Those who are facing a similar problem and want to solve it by the aws-cli then here is the solution:
Here is the official document: "If REPLACE is used, the copied object will only have the metadata values that were specified by the CLI command. Note that if you are using any of the following parameters: --content-type, content-language, --content-encoding, --content-disposition, --cache-control, or --expires, you will need to specify --metadata-directive REPLACE for non-multipart copies if you want the copied objects to have the specified metadata values."