question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I am not sure if this is in scope for this project. But I can’t figure out how to have Feather JS accept a file from <FileInput>

Can someone point give some pointers? Thanks!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
AshotNcommented, Aug 10, 2021

Thank you kindly for this, that exactly what I needed. On a similar note, is there a way to set the form as a enctype="multipart/form-data"? Thanks again for the help.

1reaction
josxcommented, Aug 9, 2021

it is out of the scope, but i can share with you some legacy code on how to do it:

client:

const dataProvider = restClient(feathersClient, { id: '_id', usePatch: true });

export class OperacionCreate extends Component {
  constructor(props) {
    super(props);
    this.state = {
      currentFile: null,
      result: null,
      isSaving: false
    }
    this.clickHandler = this.handleClick.bind(this)
    this.fileHandler = this.onFileChange.bind(this)
  }
  onFileChange(file) {
    this.setState({currentFile: file})
  }
  handleClick() {
    if (!this.state.isSaving && this.state.currentFile){
      this.setState({isSaving: true})
      convertFileToBase64(this.state.currentFile).then((convertedFile)=>{
        dataProvider(CREATE, 'operaciones', { data: {uri: convertedFile}})
        .then((resp) => {
          this.setState({result: resp.data.data})
        }).finally(()=> {
          this.setState({isSaving: false})
        })
      })
    }
  }
  render() {
    return (
      <Create {...this.props} title="Importar Operaciones">
        <SimpleForm toolbar={<OperacionToolbar isSaving={this.state.isSaving} handleClick={this.clickHandler}/>} redirect={false} >
          <FileInput onChange={this.fileHandler} source="uri" label="Planilla de Operacion" accept="application/vnd.ms-excel" validate={[required()]}>
            <FileField source="src" title="title" />
          </FileInput>
          {
            this.state.result ?
              <ResultadoDeCarga result={this.state.result}/>
              : null
          }
        </SimpleForm>
      </Create>
    );
  }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Easyupload.io - Upload files for free and transfer big files easily.
Easyupload.io offers free file upload, file sharing and file transfer service without any need for registration. Upload your files and share them with...
Read more >
Upload Files Of Any Size – Free Up To 5 GB - Filemail
Upload files free and share anonymously using a direct download link. No download limits. No Ads. No need to register. Share more with...
Read more >
file.io - Super simple file sharing
Sharing files with file.io is convenient, anonymous and secure. Just upload files and share the links via email, SMS, Slack, Discord, etc.
Read more >
WeTransfer - Send Large Files & Share Photos Online - Up to ...
WeTransfer is the simplest way to send your files around the world. Share large files and photos. Transfer up to 2GB free. File...
Read more >
Dropbox.com
Canvas. Upload course files or assignments straight from Dropbox to Canvas.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found