@adminforth/upload 2.5.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +6 -0
- package/index.ts +8 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -23,6 +23,12 @@ export default class UploadPlugin extends AdminForthPlugin {
|
|
|
23
23
|
// for calcualting average time
|
|
24
24
|
this.totalCalls = 0;
|
|
25
25
|
this.totalDuration = 0;
|
|
26
|
+
this.getFileDownloadUrl = (path_1, ...args_1) => __awaiter(this, [path_1, ...args_1], void 0, function* (path, expiresInSeconds = 1800) {
|
|
27
|
+
if (!path) {
|
|
28
|
+
return '';
|
|
29
|
+
}
|
|
30
|
+
return this.options.storageAdapter.getDownloadUrl(path, expiresInSeconds);
|
|
31
|
+
});
|
|
26
32
|
if ((_b = (_a = this.options.generation) === null || _a === void 0 ? void 0 : _a.rateLimit) === null || _b === void 0 ? void 0 : _b.limit) {
|
|
27
33
|
this.rateLimiter = new RateLimiter((_c = this.options.generation.rateLimit) === null || _c === void 0 ? void 0 : _c.limit);
|
|
28
34
|
}
|
package/index.ts
CHANGED
|
@@ -21,6 +21,8 @@ export default class UploadPlugin extends AdminForthPlugin {
|
|
|
21
21
|
|
|
22
22
|
rateLimiter: RateLimiter;
|
|
23
23
|
|
|
24
|
+
getFileDownloadUrl: ((path: string) => Promise<string>);
|
|
25
|
+
|
|
24
26
|
constructor(options: PluginOptions) {
|
|
25
27
|
super(options, import.meta.url);
|
|
26
28
|
this.options = options;
|
|
@@ -28,6 +30,12 @@ export default class UploadPlugin extends AdminForthPlugin {
|
|
|
28
30
|
// for calcualting average time
|
|
29
31
|
this.totalCalls = 0;
|
|
30
32
|
this.totalDuration = 0;
|
|
33
|
+
this.getFileDownloadUrl = async (path: string, expiresInSeconds: number = 1800) : Promise<string> => {
|
|
34
|
+
if (!path) {
|
|
35
|
+
return '';
|
|
36
|
+
}
|
|
37
|
+
return this.options.storageAdapter.getDownloadUrl(path, expiresInSeconds);
|
|
38
|
+
}
|
|
31
39
|
if (this.options.generation?.rateLimit?.limit) {
|
|
32
40
|
this.rateLimiter = new RateLimiter(this.options.generation.rateLimit?.limit)
|
|
33
41
|
}
|