Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bucket is requester pays bucket but no user project provided

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&amp;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.

like image 513
Karlygash Zhuginisova Avatar asked Dec 10 '17 14:12

Karlygash Zhuginisova


People also ask

What is the purpose of requester pays?

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.

How do I give a public access to a bucket in GCP?

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.

What is the limit on bucket create Delete per project?

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.


1 Answers

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:

  • The caller is the owner of the bucket, or
  • The caller has the 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

like image 67
Brandon Yarbrough Avatar answered Sep 23 '22 13:09

Brandon Yarbrough