Custom Hostname not consistent bucket name for signed storage policy uploads
sca1235 opened this issue · 1 comments
sca1235 commented
Environment details
- OS: Ubuntu
- PHP version: 8.3
- Package name and version: Lastest v0.270.0
Steps to reproduce
- We are trying to use a custom domain for our private bucket. Currently creating signed urls works fine with the normal storage.googleapis.com endpoint. But we want to generate the policy and upload to our custom domain at secure-upload-test.example.com
- We use Google loadbalancer with domain using A record. So the domain points to the private bucket.
- Error we get
Bucket name from the request URI is not consistent with what is provided in the form.
- We tried setting custom endpoint when setting up the client but it didn't affect.
- We set the bucketBoundHostname but that is where we are stuck as get the above error. Our bucket name will not match the custom endpoint. https://cloud.google.com/storage/docs/request-endpoints#a
Code example
# example
$bucketName = test123
$sign = $bucket->generateSignedPostPolicyV4($filename, now()->addMinute(), [
'bucketBoundHostname'=> "secure-upload-test.example.com",
'scheme'=>'https',
'conditions' => [
['acl' => 'bucket-owner-read'],
['eq', '$Content-Type', $type],
// ["eq", '$Content-Encoding', 'gzip'],
['content-length-range', 0, $maxRange]
],
'fields' => [
'bucket' => $bucketName,
]
]);
We reviewed all this code and don't see anything different we should be doing.
sca1235 commented
We tried with CNAME and it works. So if anyone ever runs across this use cname instead of loadbalancer.