fiberx-backend-toolkit 0.1.16 → 0.1.17
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.
|
@@ -40,8 +40,8 @@ class FileUploadProcessor {
|
|
|
40
40
|
// ==============================
|
|
41
41
|
// KEY GENERATION
|
|
42
42
|
// ==============================
|
|
43
|
-
generateKey(category,
|
|
44
|
-
return `${
|
|
43
|
+
generateKey(category, folder, file_name) {
|
|
44
|
+
return `${category}/${folder}/${file_name}`;
|
|
45
45
|
}
|
|
46
46
|
// ==============================
|
|
47
47
|
// MAIN METHOD
|
|
@@ -55,13 +55,15 @@ class FileUploadProcessor {
|
|
|
55
55
|
return { status: false, msg: v_msg };
|
|
56
56
|
}
|
|
57
57
|
const ext = this.getExtension(input.original_name);
|
|
58
|
-
const
|
|
58
|
+
const file_name = `${(0, uuid_1.v4)()}.${ext}`;
|
|
59
|
+
const key = this.generateKey(category, input.folder ?? "uploads", file_name);
|
|
59
60
|
const stored = await this.driver.upload(key, input.file, input.mime_type, input.is_public ?? true);
|
|
60
61
|
if (!stored) {
|
|
61
62
|
return { status: false, msg: "failed_to_store_file" };
|
|
62
63
|
}
|
|
63
64
|
const result = {
|
|
64
65
|
key,
|
|
66
|
+
file_name,
|
|
65
67
|
original_name: input.original_name,
|
|
66
68
|
mime_type: input.mime_type,
|
|
67
69
|
category,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fiberx-backend-toolkit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
4
4
|
"description": "A TypeScript backend toolkit providing shared domain logic, infrastructure helpers, and utilities for FiberX server-side applications and services.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./dist/index.js",
|