kimmelsg / cj-upload Goto Github PK
View Code? Open in Web Editor NEWHigher order React components for file uploading (with progress) react file upload
License: MIT License
Higher order React components for file uploading (with progress) react file upload
License: MIT License
In Uploader component, in onError prop callback I get as argument of function only one boolean value, instead of full server response (which include validation on additional data sent with files and on the file itself).
With only a true/false flag I can't expose to the user the validation error in order to get a valid submission.
I am missing somenthing in docs or it is a feature not yet implemented ?
3q
Currently, only the first file selected is sent, this library doesn't support multiple. I don't need this at the moment, so if anyone has ideas on how to add this in, let me know.
const Overlay = ({removeComponent, index, changeImage}) =>
<View style={{position: 'absolute'}} >
<UploadField onFiles={files=>console.log('dfs')} >
<View style={[s.overlay, s.size]}>
<Text style={s.replace}>Replace</Text>
</View>
</UploadField>
<CloseIcon index={index} removeComponent={removeComponent}/>
</View>
Hey,
Thanks for this useful library!
I would like to add a listener on the input for onDragEnter
and onDragExit
. Would it be possible to accept a inputRef
prop, which would be forwarded to the input?
I could make the PR if you would like.
Thanks in advance!
Thank you for sharing this great project. Really handy!
If e.g. I upload a file to S3, it returns a 204
which is not an error. Nevertheless UploadRequest
will resolve to:
{
error: true,
response: "",
status: 204
}
Also there are a lot more 2xx
success statuses (https://httpstatuses.com/). I think you shouldn't set error: true
for them either...
Probably due to the css framework or some resetter I have the input with the following styles:
top: 0px;
right: 0px;
opacity: 0;
width: 100%;
height: 100%;
cursor: pointer;
position: absolute;
This means that wherever I click the upload is triggered.
How can I apply styles over the <input/>
?
I tried with <UploadField style={{ width: 0, height: 0 }}
without success.
How to limit the size of uploaded files?
Now uploading multiple images at once, will be merged into one request, and some servers do not support this form.
In addition, sometimes we have to upload multiple pictures at the same time. So, I want to detect that when uploading multiple pictures, I divide them into multiple requests and merge them into one return result. What do you think?
I can able to detect the error on onError
but the files array and progress is still there even after the error. How to reset everything on onError
and onComplete
? @zackify
I need to change state if the user hits cancel on the file dialog.
Expected result
Upload is triggered
Actual result
Upload is not triggered
Note:
If a new file is selected upload starts, maybe the issue is in the "onChange" handler of the file input field.
Need to check the request variables before being sent to make sure they are correct
Something like:
await uploadRequest(options, progress => console.log(progress)
I carefully read your source code. The onfils method is passed by uploader,wo cannot change it, so, how to get files before upload?
<Uploader
request={{
fileName: 'file',
url: 'https://upload.com',
method: 'POST',
fields: {
//extra fields to pass with the request
full_name: 'Testing extra fields',
},
headers: {
//custom headers to send along
Authorization: 'Bearer: Test',
},
// use credentials for cross-site requests
withCredentials: false,
}}
onComplete={({ response, status }) => /*do something*/}
//upload on file selection, otherwise use `startUpload`
uploadOnSelection={true}
>
{({ onFiles, progress, complete }) => (
// onfile is the inner function
<div>
<UploadField onFiles={onFiles}>
<div>
Click here to select a file!
</div>
</UploadField>
{progress ? `Progress: ${progress}` : null}
{complete ? 'Complete!' : null}
</div>
)}
</Uploader>
i want to limit the uploaded flles, i do not kown to code
i have see #27
Hey,
Been using the imperative API for a while now and it works great, just upgraded my app to react 16, tested it out and it runs very smoothly. Still have this dependancy warning from yarn though " > @navjobs/[email protected]" has incorrect peer dependency "react@^15.3.1". It's the only package ive got left in my tree that has the warning, just wanted to say something about it.
cheers
Hey, this seems like the most legit uploader lib i've seen so far, but i'm having a little trouble implementing the imperative API version in a redux action, maybe you can shed light on what I'm doing wrong or if there is actually an issue. When I run the UploadRequest on a file I get back this value for instance which is undefined.
Which logs the following error:
Here is what my call looks like:
I've verified all the params url, hash, mimetype, auth etc.
This is for a multipart file uploader (for my work) and there aren't really a whole lot of other nice options to do this out there at the moment, so would love to get this very elegant one to work.
I am unable to get response headers when using UploadRequest to upload files.
As per documentation of UploadRequest there is no way of reading response headers.
Can we add this feature?
Is there a way to reset the uploader state?
More specifically what I mean, is how can I reset progress and complete?
I don't see this implemented. but it would be really helpful IMO.
BTW thank you for this lib :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.