File Upload
Opened this issue · 3 comments
Lory1990 commented
Is it possibile to upload file via post?
lexich commented
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 commented
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 commented
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