Comments (6)
I wouldnt like to expose the uploader instance unless there's a very strong case for it
In any case, Ive a solution I believe will work nicely. Abort will take care of pending uploads and Uploady context will have the clearPending method available.
This way you'll be able to cancel individual (pending) uploads or all of them together
from react-uploady.
@LukasOchmann is this the actual code youre using?
the hooks you use in this code are outside the context provider. So this wont work.
You should actually be getting an error.
If this isnt the actual code, please provide an updated version or codesandbox
from react-uploady.
It is an reduces version. My Example was wrong.
from react-uploady.
@yoavniran i created a Sandbox: https://codesandbox.io/s/vibrant-cdn-b25h6?fontsize=14&hidenavigation=1&theme=dark
from react-uploady.
There are a few things going on here:
-
Currently abort cannot be used on items that are not already uploading.
-
There is currently no way to clear pending uploads (autoUploads = false) from the UI components. The Uploader instance does have a clearPending method but its not exposed to the UploadyContext API.
-
clearPending doesnt have the granularity to remove a single item, only all pending batches
-
there's a bug in your codesandbox, line 43, youre calling the abort method when passing it to the button onClick instead of when the button is clicked. This wont work of course but Im guessing its just a mistake in the sandbox and not your actual code.
-
even if everything worked as you need. You would need to remove the aborted file from your UI (files state). Probably using using the abort event listeners.
With all that in mind, I will need to think of a way to make it easy to remove pending batch items. I think modifying the abort methods is the best approach since it will make it a single flow instead of having implementations decide which flow to use based on internal Uploader state. WDYT?
I will look into adding this as a feature soon.
from react-uploady.
Thank you for your Response and for accepting it as an enhancement,
yes line 43 was a mistake, i was in a hurry....
i also prefer an solution wich modifies the abort method. With an extra method for that usecase i had to evaluate the current files state instead of simply aborting it.
As an alternativ to exposing the Uploder instance, could the Uplody take a prop "instance" wich takes in an custom Uploder Instance? or maybe an higher order Component withCustomUploder
from react-uploady.
Related Issues (20)
- Retry doesnt "remember" SendOptions HOT 4
- Allow clearing a single preview using the UploadPreview methods HOT 1
- event UPLOADER_EVENTS.ITEM_FINISH gets fired only once when uploading multiple files HOT 3
- Canceled batch is processed the next time I choose a file HOT 5
- error in production: Cannot assign to read only property 'state' of object '#' HOT 3
- Not working with edge runtime HOT 5
- nextjs 13.4 issue with react-uploady - Expected server HTML to contain a matching <input> in <div> HOT 3
- Clicking to crop image using react-image-crop makes the image disappear HOT 1
- BATCH_FINALIZE and BATCH_FINISH listeners not calling HOT 7
- use*ProgressListener reports uneven completed percentage when files are different sizes HOT 2
- Support for userData in upload options HOT 4
- Make uploadResponse and uploadStatus accessible inside useItemErrorListener with ChunkedUploady HOT 4
- Upload function is not working for createUploader object from @rpldy/uploader package HOT 3
- Batch progress completion incorrect when using mock sender HOT 9
- cancellable hooks types dont allow asynchronousity HOT 1
- export `getPreviewsLoaderHook` for public use HOT 4
- UploadDropZone: Child Element Handling in onDragLeave has issues HOT 3
- Initial Post Request doesnt set header "Upload-Concat": "partial" when parallel is >1 HOT 3
- file field is required error HOT 4
- TusUploady + supabase storage gives ChunkedSendError: start byte 84715 is invalid. File size: 84715 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-uploady.