Last active
November 1, 2021 21:19
-
-
Save shaffeeullah/198749e5cbd5f70cb100ee90b320bea5 to your computer and use it in GitHub Desktop.
Generate a Google Cloud Storage Signed URL to download data via GET request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function getReadSignedUrl(bucketName, filename, minutesToExpiration) { | |
const storage = new Storage(); | |
const options = { | |
version: 'v4', | |
action: 'read', | |
expires: minutesToExpiration * 60 * 1000 + Date.now(), | |
}; | |
const [url] = await storage | |
.bucket(bucketName) | |
.file(filename) | |
.getSignedUrl(options); | |
return url; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment