Skip to content

Storage: Missing support for beginSignedUploadSession origin (cors) configuration  #1056

@illambo

Description

@illambo

https://github.com/GoogleCloudPlatform/google-cloud-php/blob/981ea50a6954d1cbe464417ac822fa21d2d8887f/Storage/src/StorageObject.php#L956

Hello, I found configuration issues about origin (cors) configuration with beginSignedUploadSession for give the ability to start the resumable upload from client browser.
With debug I found is related to SignedUrlUploader.createResumeUri method.

In fact I try forcing with this and it works

$headers = [
      'Content-Type' => $this->contentType,
      'Content-Length' => 0,
      'x-goog-resumable' => 'start',
      'Origin' => '*',
]; 

From the api documentation (initiating a resumable upload session, point 5)

  • If you have enabled Cross-Origin Resource Sharing, an Origin header that you use in subsequent upload requests for the file you are uploading.

Seems nodejs sdk already have some implementation about that.

Currently my work around is:

// step 1 - signedUploadUrl (POST)
$signed_upload_url = $object->signedUploadUrl($signed_upload_url_expire_at, []);

$headers = [
  'Content-Length' => 0,
  'x-goog-resumable' => 'start',
  'Origin' => '*'
];

// step 2 - beginSignedUploadSession (POST)
$httpClient = new GuzzleClient([]);
$response = $httpClient->post($signed_upload_url, [
   'headers' => $headers,
]);

if (in_array($response->getStatusCode(), [200, 201])) {
  $signed_upload_url = $response->getHeader('Location')[0];
}

// ..

Is it possible to integrate the configuration or get more information about it?
Thanks

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the Cloud Storage API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions