Coder Social home page Coder Social logo

kimmelsg / cj-upload Goto Github PK

View Code? Open in Web Editor NEW
585.0 585.0 33.0 1.14 MB

Higher order React components for file uploading (with progress) react file upload

License: MIT License

JavaScript 100.00%
file file-upload progress react react-components upload upload-dialog xhr

cj-upload's People

Contributors

danielberndt avatar dreamorosi avatar edongashi avatar ingro avatar manish-tal avatar manishk3008 avatar mikegolod avatar mjsisley avatar zackify avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cj-upload's Issues

Unable to catch error response details

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 ?

Support multiple files at once

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.

onFiles never called.

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>

Access the input ref

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!

Styling input[type=file]

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.

Support multiple files and returning a list of states

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?

Upload twice same file do not trigger upload

  • Upload a file with UploadField
  • Wait for upload to complete
  • Try to upload the same file

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.

Add imperative api

Something like:

await uploadRequest(options, progress => console.log(progress)

How to get files before upload?

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

React 16 Upgrade

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

TypeError: instance is not a function

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.

screen shot 2017-10-31 at 5 35 39 pm

Which logs the following error:

screen shot 2017-10-31 at 5 44 52 pm

Here is what my call looks like:

screen shot 2017-10-31 at 5 44 02 pm

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.

Reset uploader state

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 :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.