the_bell_oper
the_bell_oper

Reputation: 11

Google Storage PHP client: Can't create object by POSTing to signed URL

We're using the Google\Cloud\Storage\StorageObject's signedUploadUrl method in the backend to generate upload URLs for our JS-based clients to be able to upload data into these URLs without need of authentication.

This URL is then retrieved by the clients, which in turn start a resumable upload by creating a storage object with a POST request in order to obtain an upload_id, and subsequent PUT requests would add data to it making use of this upload_id as authenticating factor.

Problem we're facing is that this signed upload URL is not behaving as expected: we're supposed to POST metadata (file name, content type) to it in order to obtain an upload_id, but this request fails with "SignatureDoesNotMatch".

As we're using the official PHP client library, we're clueless on what can be happening for this to be not working.

Upvotes: 1

Views: 123

Answers (1)

Bricktop
Bricktop

Reputation: 67

Did you try to send content-type header together with your subsequent PUT requests ? Since generated signed upload URL is being created together with content-type header, subsequent PUT requests must send the same header.

Have a look at here: google-cloud-php

options->contentType: If you provide this value, the client must provide this HTTP header set to the same value.

Upvotes: 1

Related Questions