Skip to content

Commit 25e6613

Browse files
committed
feat: add getFileDownloadUrl method for the plugin
1 parent d0dfb0c commit 25e6613

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,21 @@ export default class UploadPlugin extends AdminForthPlugin {
2020

2121
rateLimiter: RateLimiter;
2222

23+
getFileDownloadUrl: ((path: string) => Promise<string>);
24+
2325
constructor(options: PluginOptions) {
2426
super(options, import.meta.url);
2527
this.options = options;
2628

2729
// for calcualting average time
2830
this.totalCalls = 0;
2931
this.totalDuration = 0;
32+
this.getFileDownloadUrl = async (path: string, expiresInSeconds: number = 1800) : Promise<string> => {
33+
if (!path) {
34+
return '';
35+
}
36+
return this.options.storageAdapter.getDownloadUrl(path, expiresInSeconds);
37+
}
3038
if (this.options.generation?.rateLimit?.limit) {
3139
this.rateLimiter = new RateLimiter(this.options.generation.rateLimit?.limit)
3240
}

0 commit comments

Comments
 (0)