@google-cloud/storage#GetSignedUrlConfig TypeScript Examples

The following examples show how to use @google-cloud/storage#GetSignedUrlConfig. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.ts    From Dimensions with MIT License 6 votes vote down vote up
/**
   * Returns a download URL to use to download an object
   * @param key - key referencing the object to download
   */
  async getDownloadURL(key: string): Promise<string> {
    const options: GetSignedUrlConfig = {
      version: 'v4',
      action: 'read',
      expires: new Date().getTime() + 15 * 60 * 1000,
    };
    return this.dimensionBucket
      .file(key)
      .getSignedUrl(options)
      .then((url) => {
        return url[0];
      });
  }