Skip to content

Commit

Permalink
Merge branch 'ryanto:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
martinmiglio authored Oct 9, 2023
2 parents 3051b61 + 4391c7c commit 9c42074
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/docs-site/src/pages/use-s3-upload.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,4 @@ The `files` array returned from `useS3Upload()` contains a list of files that ar
| `uploaded` | An integer representing the total number of bytes that been uploaded so far. |
| `size` | An integer representing the total size of the file. |
| `progress` | The percentage (between 0 and 100) of the file that has been uploaded. |
| `id` | A unique identifier for the file. |
2 changes: 1 addition & 1 deletion packages/next-s3-upload/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.3.0",
"version": "0.3.2",
"license": "MIT",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
Expand Down
11 changes: 10 additions & 1 deletion packages/next-s3-upload/src/hooks/use-upload-files.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React from 'react';
import { FileInput } from '../components/file-input';
import { useRef, useState } from 'react';
import { uuid } from '../utils/keys';

type TrackedFile = {
file: File;
progress: number;
uploaded: number;
size: number;
id: string;
};

export const useUploadFiles = () => {
Expand All @@ -31,6 +33,7 @@ export const useUploadFiles = () => {
? {
file,
uploaded,
id: trackedFile.id,
size: file.size,
progress: file.size ? (uploaded / file.size) * 100 : 0,
}
Expand All @@ -42,7 +45,13 @@ export const useUploadFiles = () => {
let addFile = (file: File) => {
setFiles(files => [
...files,
{ file, progress: 0, uploaded: 0, size: file.size },
{
file,
progress: 0,
uploaded: 0,
size: file.size,
id: uuid(),
},
]);
};

Expand Down

0 comments on commit 9c42074

Please sign in to comment.