I am trying to POST image to google cloud storage via multipart request using their JSON API, but I am receiving an error:
"code": 400,
"message": "Bucket is requester pays bucket but no user project provided."
HERE IS MY REQUEST:
POST /upload/storage/v1/b<my_bucket_here>/o?
uploadType=multipart&name=testPostman HTTP/1.1
Host: www.googleapis.com
Content-Length: 2139
Authorization: Bearer ya29.<my_token_here>
Cache-Control: no-cache
Postman-Token: 6fb40df7-3a0d-fda6-a94e-63365f594c9d
Content-Type: multipart/form-data; boundary=----
WebKitFormBoundary7MA4YWxkTrZu0gW
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="data"; filename="profilephotos-
960x640.jpg"
Content-Type: image/jpeg
I tried going to my bucket, and project IS specified there. The only thing that looks strange is Lifecycle part, which is None, and when I click to change it, it opens a page Failed to open. This is so weird.
Can it be because I am not the owner, but an Admin of the project? Billing is enabled for the bucket. Please help! Spent 3 days for this already.
With Requester Pays buckets, the requester instead of the bucket owner pays the cost of the request and the data download from the bucket. The bucket owner always pays the cost of storing data.
In the Google Cloud console, go to the Cloud Storage Buckets page. In the list of buckets, click on the name of the bucket that you want to make public. Select the Permissions tab near the top of the page. In the Permissions section, click the + Add button.
There is a per-project rate limit to bucket creation and deletion. This rate limit is approximately 1 request every 2 seconds, so plan on fewer buckets and more objects in most cases.
The "requester pays" feature of Google Cloud Storage allows the owner of the bucket pays for the cost of storing the objects, but the users of the bucket to pay for the cost of using the bucket.
Once requester pays has been enabled, every request needs to specify which project is to be billed for that request. The only exceptions are:
resourcemanager.projects.createBillingAssignment
permission for the bucket's project.Otherwise, you'll need to explicitly specify a project to be billed by including the URL parameter userProject=myProjectId
. So, in your case, make this change to the URL you're invoking:
POST /upload/storage/v1/b/o?userProject=YOUR-PROJECT&uploadType=multipart&name=testPostman
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