nuxt-file-storage 0.2.2 → 0.2.5

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
@@ -108,18 +108,20 @@ const submit = async () => {
108
108
  using Nitro Server Engine, we will make an api route that recieves the files and stores them in the folder `userFiles`
109
109
  ```ts
110
110
  export default defineEventHandler(async (event) => {
111
- const { file } = await readBody<{ file: File }>(event)
111
+ const { files } = await readBody<{ files: File[] }>(event)
112
112
 
113
- await storeFileLocally(
114
- file.content, // the stringified version of the file
115
- file.name, // the name of the file
116
- '/userFiles' // the folder the file will be stored in
117
- )
113
+ for ( const file of files ) {
114
+ await storeFileLocally(
115
+ file.content, // the stringified version of the file
116
+ 8, // you can add a name for the file or length of Unique ID that will be automatically generated!
117
+ '/userFiles' // the folder the file will be stored in
118
+ )
118
119
 
119
- // {OR}
120
+ // {OR}
120
121
 
121
- // Parses a data URL and returns an object with the binary data and the file extension.
122
- const { binaryString, ext } = parseDataUrl(file.content)
122
+ // Parses a data URL and returns an object with the binary data and the file extension.
123
+ const { binaryString, ext } = parseDataUrl(file.content)
124
+ }
123
125
 
124
126
  return 'success!'
125
127
  })
@@ -157,4 +159,4 @@ npm run dev
157
159
  [license-src]: https://img.shields.io/npm/l/nuxt-file-storage.svg?style=flat&colorA=18181B&colorB=28CF8D
158
160
  [license-href]: https://npmjs.com/package/nuxt-file-storage
159
161
  [nuxt-src]: https://img.shields.io/badge/Nuxt-18181B?logo=nuxt.js
160
- [nuxt-href]: https://nuxt.com
162
+ [nuxt-href]: https://nuxt.com/modules/nuxt-file-storage
package/dist/module.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "nuxt-file-storage",
3
3
  "configKey": "fileStorage",
4
- "version": "0.2.2"
4
+ "version": "0.2.5"
5
5
  }
package/dist/module.mjs CHANGED
@@ -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
  // },
@@ -2,6 +2,7 @@ export default function (): {
2
2
  files: import("vue").Ref<{
3
3
  content: any;
4
4
  name: string;
5
+ lastModified: string;
5
6
  readonly size: number;
6
7
  readonly type: string;
7
8
  arrayBuffer: () => Promise<ArrayBuffer>;
@@ -6,6 +6,10 @@ export default function() {
6
6
  reader.onload = (e) => {
7
7
  files.value.push({
8
8
  ...file,
9
+ name: file.name,
10
+ size: file.size,
11
+ type: file.type,
12
+ lastModified: file.lastModified,
9
13
  content: e.target.result
10
14
  });
11
15
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-file-storage",
3
- "version": "0.2.2",
3
+ "version": "0.2.5",
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",