generated from it-at-m/oss-repository-en-template
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* #920: add reader support for file input * #920: fix NaN on file size * #920: merge with dev * #920:fix nvda bugs
- Loading branch information
1 parent
eb03b78
commit f9b3c4a
Showing
6 changed files
with
111 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
digiwf-apps/packages/components/digiwf-multi-file-input/src/middleware/fileSize.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export const formatBytes = (size: number, decimals: number = 2) => { | ||
const k = 1024; | ||
const dm = decimals < 0 ? 0 : decimals; | ||
const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]; | ||
|
||
const i = Math.floor(Math.log(size) / Math.log(k)); | ||
|
||
return ( | ||
parseFloat((size / Math.pow(k, i)).toFixed(dm)) + | ||
" " + | ||
sizes[i] | ||
); | ||
} |
17 changes: 17 additions & 0 deletions
17
digiwf-apps/packages/components/digiwf-multi-file-input/src/middleware/url.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export const createBlobUrl = (byteCharacters: string, type: string): string => { | ||
|
||
const byteArrays: Uint8Array[] = []; | ||
|
||
for (let offset = 0; offset < byteCharacters.length; offset += 1024) { | ||
const slice = byteCharacters.slice(offset, offset + 1024); | ||
|
||
const byteNumbers = new Array(slice.length); | ||
for (let i = 0; i < slice.length; i++) { | ||
byteNumbers[i] = slice.charCodeAt(i); | ||
} | ||
const byteArray = new Uint8Array(byteNumbers); | ||
byteArrays.push(byteArray); | ||
} | ||
const blob = new Blob(byteArrays, {type: type}); | ||
return URL.createObjectURL(blob); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters