mktcms 0.1.13 → 0.1.14
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/module.json
CHANGED
|
@@ -39,8 +39,7 @@ export default defineEventHandler(async (event) => {
|
|
|
39
39
|
statusMessage: "Invalid file type. Only PDF, JPG, JPEG, and PNG files are allowed."
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
-
const filePath = [s3Prefix, sanePath, sanitizeFilename(file.filename)].filter(Boolean).join("
|
|
42
|
+
const filePath = [s3Prefix, sanePath, sanitizeFilename(file.filename)].filter(Boolean).join(":");
|
|
43
43
|
await useStorage("content").setItemRaw(filePath, Buffer.from(file.data));
|
|
44
|
-
|
|
45
|
-
return { success: true, path: returnFileName };
|
|
44
|
+
return { success: true, path: filePath };
|
|
46
45
|
});
|
|
@@ -12,7 +12,7 @@ export default defineEventHandler(async (event) => {
|
|
|
12
12
|
const file = await storage.getItem(fullPath);
|
|
13
13
|
if (!file) {
|
|
14
14
|
const fallbackStorage = useStorage("fallback");
|
|
15
|
-
const fallbackFile = await fallbackStorage.getItem(
|
|
15
|
+
const fallbackFile = await fallbackStorage.getItem(fullPath);
|
|
16
16
|
if (fallbackFile) {
|
|
17
17
|
return fallbackFile;
|
|
18
18
|
}
|
|
@@ -3,23 +3,21 @@ import createFsDriver from "unstorage/drivers/fs";
|
|
|
3
3
|
import { defineNitroPlugin, useStorage, useRuntimeConfig } from "nitropack/runtime";
|
|
4
4
|
export default defineNitroPlugin(() => {
|
|
5
5
|
const storage = useStorage();
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
});
|
|
16
|
-
const fallbackDriver = createFsDriver({
|
|
17
|
-
base: "./content"
|
|
18
|
-
});
|
|
19
|
-
storage.mount("fallback", fallbackDriver);
|
|
20
|
-
if (process.env.NODE_ENV === "production") {
|
|
21
|
-
storage.mount("content", s3Driver);
|
|
6
|
+
const { mktcms: { s3AccessKey, s3SecretKey, s3Endpoint, s3Bucket, s3Region } } = useRuntimeConfig();
|
|
7
|
+
if (s3AccessKey && s3SecretKey && s3Endpoint && s3Bucket && s3Region) {
|
|
8
|
+
storage.mount("content", createS3Driver({
|
|
9
|
+
accessKeyId: s3AccessKey,
|
|
10
|
+
secretAccessKey: s3SecretKey,
|
|
11
|
+
endpoint: s3Endpoint,
|
|
12
|
+
bucket: s3Bucket,
|
|
13
|
+
region: s3Region
|
|
14
|
+
}));
|
|
22
15
|
} else {
|
|
23
|
-
storage.mount("content",
|
|
16
|
+
storage.mount("content", createFsDriver({
|
|
17
|
+
base: "./.storage"
|
|
18
|
+
}));
|
|
24
19
|
}
|
|
20
|
+
storage.mount("fallback", createFsDriver({
|
|
21
|
+
base: "./content"
|
|
22
|
+
}));
|
|
25
23
|
});
|