Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No resumable option for getSignedUrl? #20

Closed
lukesneeringer opened this issue Sep 21, 2017 · 6 comments
Closed

No resumable option for getSignedUrl? #20

lukesneeringer opened this issue Sep 21, 2017 · 6 comments
Assignees
Labels
api: storage Issues related to the googleapis/nodejs-storage API. help wanted We'd love to have community involvement on this issue. 🚨 This issue needs some love. triage me I really want to be triaged. web

Comments

@lukesneeringer
Copy link
Contributor

From @odigity on April 22, 2017 1:11

I've spent the last week learning about GCS, the SDK, and the Node client library, and just today finally get a prototype working that generated a signed URL on the server and passed it to the browser which used it to PUT a file.

Now I want to tackle resumable uploads for large files, and to my shock, I don't see a way to use the Node lib to make one. I even went into the code of both gsutil and the Node lib to confirm.

gsutil

If you look at the docs for gsutil, it mentions that the -m option takes both the 'GET' and 'RESUMABLE' values (not a very complete list, should probably list all possible values), and later on shows an example with 'PUT', so at least those three are specified.

If you check the code, you'll see that RESUMABLE gets converted to POST, and an x-goog-resumable header is used. Also here you'll see that all values are rejected except [ 'GET', 'PUT', 'DELETE', 'HEAD', 'RESUMABLE' ].

Node.js Library

Now take a look at the docs for getSignedUrl in the Node lib. The action option takes three values ('read', 'write', 'delete') which it says are equivalent to 'GET', 'PUT', and 'DELETE' respectively. (Not sure why these special read/write/delete values are invented for the Node lib, it just adds confusion.)

Then in the code you can see that no other values are allowed.


So, the question is: How do I use the Node lib to generate a signed URL for a resumable upload?

Copied from original issue: googleapis/google-cloud-node#2248

@lukesneeringer
Copy link
Contributor Author

From @stephenplusplus on April 22, 2017 1:24

createResumableUpload initiates a reusable upload. Our 'upload' and 'createWriteStream' methods do the re-trying automatically. If you want to handle that behavior yourself, or outside of our client, you'd use 'createResumableUpload' to get a session URI.

These are the specifications our implementation adheres to: https://cloud.google.com/storage/docs/json_api/v1/how-tos/resumable-upload

@lukesneeringer
Copy link
Contributor Author

From @odigity on April 22, 2017 1:50

I was under the impression that the Node lib is only appropriate to use in the context of:

  • server-side code
  • with authentication as a User or Service Account

Rather than in the browser for an anonymous (from GCS's perspective) user.

Are you suggesting I import the @google-cloud/storage package in my React app and use the createResumableUpload method with a signed URL?

@lukesneeringer
Copy link
Contributor Author

From @stephenplusplus on April 22, 2017 1:56

Your context assumptions are correct, but you're free to experiment in using it in others. We don't have any prescribed recipes for how to integrate with "x", but StackOverflow is a good place to tap into the community around it. In general, if you have users accessing from a browser, you would likely ping a backend to make the necessary requests to the Storage API, as opposed to doing it all through the browser.

If you do end up posting on SO, please link back so other users with the same interest can follow along. And of course, discussion can continue here with questions related to our library.

@lukesneeringer
Copy link
Contributor Author

From @odigity on April 22, 2017 8:50

Are you saying the absence of being able to use the Node.js lib to generate a signed URL for a resumable download (despite this feature existing on gsutil) is intentional, and not an oversight? Because I cannot fathom how that can be.

The end result is that I'm going to have to make my app server shell out to call gsutil instead of using the Node.js lib unless this is corrected.

@lukesneeringer
Copy link
Contributor Author

From @odigity on April 23, 2017 23:3

After several hours of working through the problem, it seems to me that you could extend getSignedUrl to support resumable simply by adding 'POST' to the list of accepted methods. Then I could manually specify the x-goog-resumable:start header using extensionHeaders.

(Until that happens, I literally have to write and maintain my own version of getSignedUrl, which is not what I want to be spending time on).

@lukesneeringer
Copy link
Contributor Author

From @stephenplusplus on April 24, 2017 14:41

Okay, thanks for finding a solution. Would you mind sending a PR? If we accepted a resumable option, it could default to specifying the correct header and action value.

@stephenplusplus stephenplusplus added the help wanted We'd love to have community involvement on this issue. label Nov 3, 2017
@ghost ghost assigned stephenplusplus Feb 5, 2018
@ghost ghost removed the type: enhancement label Feb 5, 2018
@google-cloud-label-sync google-cloud-label-sync bot added the api: storage Issues related to the googleapis/nodejs-storage API. label Jan 31, 2020
@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Apr 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/nodejs-storage API. help wanted We'd love to have community involvement on this issue. 🚨 This issue needs some love. triage me I really want to be triaged. web
Projects
None yet
Development

No branches or pull requests

4 participants