Skip to content

Commit

Permalink
add option to get a signed url for a file in AdapterGoogleCloud
Browse files Browse the repository at this point in the history
  • Loading branch information
tesirm99 committed May 13, 2024
1 parent 579203d commit 81c46bf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions src/AdapterGoogleCloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,20 @@ export class AdapterGoogleCloud extends AbstractAdapter {

// protected, called by methods of public API via AbstractAdapter

protected async _getFileAsURL(bucketName: string, fileName: string): Promise<ResultObject> {
protected async _getFileAsURL(bucketName: string, fileName: string, options: Options): Promise<ResultObject> {
try {
const file = this._client.bucket(bucketName).file(fileName);
return { value: file.publicUrl(), error: null };
if(options.signed) {
return {
value: await file.getSignedUrl({
action: 'read',
expires: options.expiresIn || 1000 * 60 * 60 * 24,
})[0],
error: null
}
} else {
return { value: file.publicUrl(), error: null };
}
} catch (e) {
return { value: null, error: e.message };
}
Expand Down

0 comments on commit 81c46bf

Please sign in to comment.