nuxt-file-storage 0.2.1 → 0.2.3
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/README.md
CHANGED
|
@@ -112,7 +112,7 @@ export default defineEventHandler(async (event) => {
|
|
|
112
112
|
|
|
113
113
|
await storeFileLocally(
|
|
114
114
|
file.content, // the stringified version of the file
|
|
115
|
-
|
|
115
|
+
8, // you can add a name for the file or length of Unique ID that will be automatically generated!
|
|
116
116
|
'/userFiles' // the folder the file will be stored in
|
|
117
117
|
)
|
|
118
118
|
|
|
@@ -157,4 +157,4 @@ npm run dev
|
|
|
157
157
|
[license-src]: https://img.shields.io/npm/l/nuxt-file-storage.svg?style=flat&colorA=18181B&colorB=28CF8D
|
|
158
158
|
[license-href]: https://npmjs.com/package/nuxt-file-storage
|
|
159
159
|
[nuxt-src]: https://img.shields.io/badge/Nuxt-18181B?logo=nuxt.js
|
|
160
|
-
[nuxt-href]: https://nuxt.com
|
|
160
|
+
[nuxt-href]: https://nuxt.com/modules/nuxt-file-storage
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineNuxtModule, createResolver, addImportsDir,
|
|
1
|
+
import { defineNuxtModule, createResolver, addImportsDir, addServerScanDir } from '@nuxt/kit';
|
|
2
2
|
import defu from 'defu';
|
|
3
3
|
|
|
4
4
|
const module = defineNuxtModule({
|
|
@@ -7,6 +7,7 @@ const module = defineNuxtModule({
|
|
|
7
7
|
configKey: "fileStorage"
|
|
8
8
|
},
|
|
9
9
|
//? Default configuration options of the Nuxt module
|
|
10
|
+
//! no defaults for now
|
|
10
11
|
// defaults: {
|
|
11
12
|
// mount: 'userFiles',
|
|
12
13
|
// },
|
|
@@ -17,34 +18,7 @@ const module = defineNuxtModule({
|
|
|
17
18
|
});
|
|
18
19
|
const resolve = createResolver(import.meta.url).resolve;
|
|
19
20
|
addImportsDir(resolve("runtime/composables"));
|
|
20
|
-
|
|
21
|
-
nuxt.hook("nitro:config", (_config) => {
|
|
22
|
-
_config.alias = _config.alias || {};
|
|
23
|
-
_config.externals = defu(typeof _config.externals === "object" ? _config.externals : {}, {
|
|
24
|
-
inline: [resolve("./runtime")]
|
|
25
|
-
});
|
|
26
|
-
_config.alias["#nuxt/file-storage"] = resolve("./runtime/server/utils/storage");
|
|
27
|
-
});
|
|
28
|
-
const template = addTemplate({
|
|
29
|
-
filename: "types/nuxt-file-storage.d.ts",
|
|
30
|
-
getContents: () => [
|
|
31
|
-
"declare module '#nuxt/file-storage' {",
|
|
32
|
-
` const storeFileLocally: typeof import('${resolve(
|
|
33
|
-
"./runtime/server/utils/storage"
|
|
34
|
-
)}').storeFileLocally`,
|
|
35
|
-
` const deleteFile: typeof import('${resolve(
|
|
36
|
-
"./runtime/server/utils/storage"
|
|
37
|
-
)}').deleteFile`,
|
|
38
|
-
"}",
|
|
39
|
-
` const parseDataUrl: typeof import('${resolve(
|
|
40
|
-
"./runtime/server/utils/storage"
|
|
41
|
-
)}').parseDataUrl`,
|
|
42
|
-
"}"
|
|
43
|
-
].join("\n")
|
|
44
|
-
});
|
|
45
|
-
nuxt.hook("prepare:types", ({ references }) => {
|
|
46
|
-
references.push({ path: template.dst });
|
|
47
|
-
});
|
|
21
|
+
addServerScanDir(resolve("./runtime/server"));
|
|
48
22
|
}
|
|
49
23
|
});
|
|
50
24
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import mimeTypes from "mime-types";
|
|
2
1
|
import { writeFile, rm, mkdir } from "fs/promises";
|
|
2
|
+
import { useRuntimeConfig } from "#imports";
|
|
3
3
|
export const storeFileLocally = async (dataurl, fileNameOrIdLength, filelocation = "") => {
|
|
4
4
|
const { binaryString, ext } = parseDataUrl(dataurl);
|
|
5
5
|
const location = useRuntimeConfig().public.fileStorage.mount;
|
|
@@ -31,6 +31,6 @@ export const parseDataUrl = (file) => {
|
|
|
31
31
|
const mime = mimeMatch[1];
|
|
32
32
|
const base64String = arr[1];
|
|
33
33
|
const binaryString = Buffer.from(base64String, "base64");
|
|
34
|
-
const ext =
|
|
34
|
+
const ext = mime.split("/")[1];
|
|
35
35
|
return { binaryString, ext };
|
|
36
36
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-file-storage",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Easy solution to store files in your nuxt apps. Be able to upload files from the frontend and recieve them from the backend to then save the files in your project.",
|
|
5
5
|
"repository": "NyllRE/nuxt-file-storage",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,11 +37,9 @@
|
|
|
37
37
|
"@nuxt/module-builder": "^0.5.5",
|
|
38
38
|
"@nuxt/schema": "^3.9.3",
|
|
39
39
|
"@nuxt/test-utils": "^3.9.0",
|
|
40
|
-
"@types/mime-types": "^2.1.4",
|
|
41
40
|
"@types/node": "^20.11.5",
|
|
42
41
|
"changelogen": "^0.5.5",
|
|
43
42
|
"eslint": "^8.56.0",
|
|
44
|
-
"mime-types": "^2.1.35",
|
|
45
43
|
"nuxt": "^3.9.3",
|
|
46
44
|
"vitest": "^1.0.0"
|
|
47
45
|
}
|