nuxt-file-storage 0.2.6 → 0.2.7

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
@@ -2,12 +2,12 @@
2
2
 
3
3
  # Nuxt File Storage
4
4
 
5
+ [![Visits Badge](https://badges.pufler.dev/visits/nyllre/nuxt-file-storage)](https://badges.pufler.dev)
5
6
  [![npm version][npm-version-src]][npm-version-href]
6
7
  [![npm downloads][npm-downloads-src]][npm-downloads-href]
7
8
  [![License][license-src]][license-href]
8
9
  [![Nuxt][nuxt-src]][nuxt-href]
9
10
 
10
-
11
11
  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.
12
12
 
13
13
  - [✨  Release Notes](/CHANGELOG.md)
@@ -82,6 +82,9 @@ You can use Nuxt Storage to get the files from the `<input>` tag:
82
82
  ```
83
83
  The `files` return a ref object that contains the files
84
84
 
85
+ > `handleFileInput` returns a promise in case you need to check if the file input has concluded
86
+
87
+
85
88
  Here's an example of using files to send them to the backend:
86
89
  ```html
87
90
  <template>
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.6"
4
+ "version": "0.2.7"
5
5
  }
package/dist/module.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { defineNuxtModule, logger, createResolver, addImportsDir, addServerScanDir } from '@nuxt/kit';
2
2
  import defu from 'defu';
3
3
 
4
- const version = "0.2.6";
4
+ const version = "0.2.7";
5
5
 
6
6
  const module = defineNuxtModule({
7
7
  meta: {
@@ -23,7 +23,7 @@ const module = defineNuxtModule({
23
23
  const previousVersion = config.public.fileStorage?.version;
24
24
  if (!previousVersion || previousVersion !== version) {
25
25
  logger.warn(
26
- `There is a breaking change in the \`fileStoreLocally\` method, link to changelog:
26
+ `There is a breaking change in the \`storeFileLocally\` method, link to changelog:
27
27
  https://github.com/NyllRE/nuxt-file-storage/releases/tag/v${version}
28
28
  `
29
29
  );
@@ -10,5 +10,5 @@ export default function (): {
10
10
  stream: () => ReadableStream<Uint8Array>;
11
11
  text: () => Promise<string>;
12
12
  }[]>;
13
- handleFileInput: (event: any) => void;
13
+ handleFileInput: (event: any) => Promise<void>;
14
14
  };
@@ -16,11 +16,14 @@ export default function() {
16
16
  reader.readAsDataURL(file);
17
17
  };
18
18
  const handleFileInput = (event) => {
19
- files.value.splice(0);
20
- console.log("handleFileInput event: " + event);
21
- for (const file of event.target.files) {
22
- serializeFile(file);
23
- }
19
+ return new Promise((resolve, reject) => {
20
+ files.value.splice(0);
21
+ const promises = [];
22
+ for (const file of event.target.files) {
23
+ promises.push(serializeFile(file));
24
+ }
25
+ Promise.all(promises).then(() => resolve()).catch((error) => reject(error));
26
+ });
24
27
  };
25
28
  return {
26
29
  files,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-file-storage",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
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",