I'm trying to set Content-Disposition and Content-Type in PostObjectV4 but it fails. Following works fine:
$options = [
['bucket' => $bucket],
['acl' => self::ACL],
['key' => $key]
];
$postObject = new PostObjectV4(
$client,
$bucket,
$formInputs,
$options,
$expires
);
But when I add the new parameters to $options it fails. I've tried only one of them and both of them. None of them works.
$options = [
['bucket' => $bucket],
['acl' => self::ACL],
['key' => $key],
['Content-Type' => 'application/octet-stream'],
['Content-Disposition' => 'attachment']
];
The errors are:
Invalid according to Policy: Policy Condition failed: ["eq", "$Content-Type", "application/octet-stream"]
Invalid according to Policy: Policy Condition failed: ["eq", "$Content-Disposition", "attachment"]
Link to option parameters: https://docs.aws.amazon.com/aws-sdk-php/v2/api/class-Aws.S3.Model.PostObject.html
The issue was that $formInputs also had to be updated with the variables which wasn't clear.
$options = [
['bucket' => $bucket],
['acl' => self::ACL],
['key' => $key],
['Content-Type' => 'application/octet-stream']
];
$formInputs = [
'key' => $key,
'acl' => self::ACL,
'Content-Type' => 'application/octet-stream'
];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With