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
Create multiple signed URLs in bulk #2077
Comments
Any updates on this? |
Have any updates on this? |
Is there any update on this? |
Hi everyone, Cloud Storage recently added matchGlob feature for list objects that makes this easier to write with the existing surface: (async () => {
const {Storage} = require('@google-cloud/storage');
// Bulk Signed URLs
// bucket has objects with objects starting with `random_file`
const bucketName = "bucketname";
const storage = new Storage();
// Recommend reading through glob support:
// matchGlob: https://cloud.google.com/storage/docs/json_api/v1/objects/list#list-objects-and-prefixes-using-glob
const [files] = await storage.bucket(bucketName).getFiles({matchGlob: "random_file*"});
files.forEach(async file => {
const [url] = await file
.getSignedUrl({
version: 'v4',
action: 'read',
expires: Date.now() + 15 * 60 * 1000, // 15 minutes
});
console.log(url);
});
})(); The minimal code to accomplish generating a list of signed URLs is short enough that it does not require additional support in the library. I want to add that there's varying performance results when running this code in a GCE instance with Application Default Credentials and service account private key being available to application in GCE.
|
@frankyn this doesn't solve the current issue.
All of this would be eliminated if we could create a single signed URL with a wildcard from the Node client. Or at the very minimum, be able to create multiple signed URLs in a single request. Both of these features are supported by the GCS platform as already explained in my first post. |
Hi @PierBover, thanks for the response, i have a few comments and questions. Please let me know if I'm misunderstanding.
I agree that the error handling is not fleshed out, but I think this can be helped by making existing getFiles and getSignedUrl methods more reliable. If you're seeing issues already those would be good to address separately.
I think these would still be the same with or without an extra helper method in the Node.js storage library though. It would just be hidden.
|
I meant other errors. Some examples:
I see what you mean now. I tried
I was expecting to get a single signed URL that would work with the wildcard. Instead So yes, you're right, it wouldn't make much of a difference. I will just close this issue because this seems like a limitation in the core GCS service which cannot be solved from a client. |
As per @shaffeeullah instructions here I'm opening this feature request.
Currently the Node storage client only allows creating signed URLs one at a time. This is very inefficient in situations where users need to upload files en masse.
Surprisingly, the
gsutil
command already supports creating URLs in bulk for multiple objects, even using a wildcard:https://cloud.google.com/storage/docs/gsutil/commands/signurl
So the feature request would be to bring this feature (which apparently already exists in the platform) to the Node client.
The text was updated successfully, but these errors were encountered: