Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File Upload #195

Open
Lory1990 opened this issue Jun 5, 2018 · 3 comments
Open

File Upload #195

Lory1990 opened this issue Jun 5, 2018 · 3 comments

Comments

@Lory1990
Copy link

Lory1990 commented Jun 5, 2018

Is it possibile to upload file via post?

@lexich
Copy link
Owner

lexich commented Jun 5, 2018

Hi @Lory1990 you can do anything what allow your adapter. Default adapter use fetch api https://github.com/lexich/redux-api/blob/master/src/adapters/fetch.js

@Lory1990
Copy link
Author

Lory1990 commented Jun 6, 2018

Hey man, i cannot upload my file... it says everytime "Buffer Zero bytes Long". This is the code:

     <input
            accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"           
            type="file"
            onChange={this.onUploadFile}
            />
            <label htmlFor="flat-button-file">
                   <IconButton component="span">
                               <Icon className={'material-icons'}>cloud_upload</Icon>
                   </IconButton>
             </label>

    onUploadFile = (e) =>{
    const {reduxApi, setError, setWait, removeWait} = this.context
    const { dispatchUploadFile } = this.props

    const fileToUpload = e.target.files[0]

    dispatchUploadFile(reduxApi, fileToUpload , (err,data)=>{
      removeWait()
      //e.target.value = null
      if(err){
        setError(err)
        return
      }
    })
  }
 [...]
   dispatchUploadFile: (reduxApi, file, cb) =>{
      dispatch(reduxApi.actions.cryptoindexUploadExcel.post(null,file,cb))
    }

may you help me? THX

@lexich
Copy link
Owner

lexich commented Jun 8, 2018

https://stackoverflow.com/questions/36067767/how-do-i-upload-a-file-with-the-js-fetch-api Try to upload your file using fetch, after that you will be able to make right post query using redux-api

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

No branches or pull requests

2 participants