diff --git a/src/AdapterAzureBlob.ts b/src/AdapterAzureBlob.ts index c869549..ef5fb65 100644 --- a/src/AdapterAzureBlob.ts +++ b/src/AdapterAzureBlob.ts @@ -181,11 +181,16 @@ export class AdapterAzureBlob extends AbstractAdapter { } try { - const options: BlobGenerateSasUrlOptions = { - permissions: BlobSASPermissions.parse("r"), - expiresOn: new Date(new Date().valueOf() + 86400), + const sasOptions: BlobGenerateSasUrlOptions = { + permissions: options.permissions || BlobSASPermissions.parse("r"), + expiresOn: options.expiresOn || new Date(new Date().valueOf() + 86400), }; - const url = await file.generateSasUrl(options); + let url: string; + if(options.isPublicFile && !options.forceSignedUrl) { + url = file.url; + } else { + url = await file.generateSasUrl(sasOptions); + } return { value: url, error: null }; } catch (e) { return { value: null, error: e.message }; diff --git a/src/AdapterGoogleCloud.ts b/src/AdapterGoogleCloud.ts index 3433712..9c5b6c2 100644 --- a/src/AdapterGoogleCloud.ts +++ b/src/AdapterGoogleCloud.ts @@ -60,7 +60,17 @@ export class AdapterGoogleCloud extends AbstractAdapter { protected async _getFileAsURL(bucketName: string, fileName: string, options: Options): Promise { try { const file = this._client.bucket(bucketName).file(fileName); - return { value: file.publicUrl(), error: null }; + if(options.isPublicFile && !options.forceSignedUrl) { + return { value: file.publicUrl(), error: null }; + } else { + return { + value: await file.getSignedUrl({ + action: 'read', + expires: options.expiresOn || 86400, + })[0], + error: null + } + } } catch (e) { return { value: null, error: e.message }; } diff --git a/src/AdapterLocal.ts b/src/AdapterLocal.ts index 15107f3..daa943e 100644 --- a/src/AdapterLocal.ts +++ b/src/AdapterLocal.ts @@ -210,6 +210,9 @@ export class AdapterLocal extends AbstractAdapter { try { const p = path.join(this._config.directory, bucketName, fileName); await fs.promises.access(p); + if(options.withoutDirectory) { + return { value: path.join(bucketName, fileName), error: null }; + } return { value: p, error: null }; } catch (e) { return { value: null, error: e.message };