Skip to content

Conversation

UniquePanda
Copy link

@UniquePanda UniquePanda commented Mar 1, 2023

Merge after #10

This adds the option to add "file categories" to the resumable object.
The categories can be set when creating the resumable instance, by passing an array of strings as the fileCategories parameter of the options object. Each string represents one file category (it's the name of the category).
Afterwards all functions that add files to the instance accept an optional fileCategory parameter. These functions are assignBrowse/assignDrop (all files added via the dom elements get the same category), respective handleChangeEvent/handleDropEvent and addFile/addFiles.
Additionally all related events (e.g. fileProcessingBegin) and all related helper functions (generateUniqueIdentifier, validateFiles + all added file validators) get the corresponding file category.

If no category is passed the defaultFileCategory is used. It can also be set via an options parameter and is called default by default. In this case, resumable should behave exactly like before.

The biggest change in the inner workings of the package is that the files are now not all stored in one files array, but in multiple array which are all added to the files object. This object has one entry per file category (and each entry is an array with all files of that category).

Two changes in the bundling are also done in this PR:
I added the copy-webpack-plugin to copy over the types/types.d.ts file into the dist directory. It was previously missing, so that some files in the dist directory had unresolved type imports.
Additionally there is now a second output of the webpack run, the helpers.js file. This allows for import of the helper functions used by resumable. This is especially handy if you want to set an own function to generate the unique identifier but want it to be based on the same algortihm used by resumable.

@UniquePanda UniquePanda linked an issue Mar 1, 2023 that may be closed by this pull request
@UniquePanda UniquePanda self-assigned this Mar 1, 2023
@UniquePanda UniquePanda changed the title Add option to distinguish between different kind of files Draft: Add option to distinguish between different kind of files Mar 1, 2023
@UniquePanda UniquePanda force-pushed the 5-add-option-to-distinguish-between-different-kind-of-files branch 10 times, most recently from 0c0cc1e to 16f2f0c Compare March 2, 2023 15:15
@UniquePanda UniquePanda changed the title Draft: Add option to distinguish between different kind of files Add option to distinguish between different kind of files Mar 3, 2023
@UniquePanda UniquePanda force-pushed the 5-add-option-to-distinguish-between-different-kind-of-files branch 2 times, most recently from 8a7e5df to 9a3e31e Compare March 13, 2023 13:21
@UniquePanda UniquePanda force-pushed the 5-add-option-to-distinguish-between-different-kind-of-files branch from 9a3e31e to b7b6141 Compare March 16, 2023 09:55
@adi64 adi64 merged commit e1c1f9a into main Mar 20, 2023
@adi64 adi64 deleted the 5-add-option-to-distinguish-between-different-kind-of-files branch March 20, 2023 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add option to distinguish between different kind of files
2 participants