{"id":13422040,"url":"https://github.com/ngokevin/react-file-reader-input","last_synced_at":"2025-11-13T22:48:24.212Z","repository":{"id":36875067,"uuid":"41182046","full_name":"ngokevin/react-file-reader-input","owner":"ngokevin","description":"React file input component for complete control over styling and abstraction from file reading.","archived":false,"fork":false,"pushed_at":"2020-06-15T11:16:12.000Z","size":81,"stargazers_count":118,"open_issues_count":5,"forks_count":27,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-06T12:43:06.673Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ngokevin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-21T23:36:57.000Z","updated_at":"2024-12-23T04:55:03.000Z","dependencies_parsed_at":"2022-09-11T00:22:15.381Z","dependency_job_id":null,"html_url":"https://github.com/ngokevin/react-file-reader-input","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngokevin%2Freact-file-reader-input","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngokevin%2Freact-file-reader-input/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngokevin%2Freact-file-reader-input/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngokevin%2Freact-file-reader-input/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ngokevin","download_url":"https://codeload.github.com/ngokevin/react-file-reader-input/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247767236,"owners_count":20992548,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T23:00:35.926Z","updated_at":"2025-11-13T22:48:19.190Z","avatar_url":"https://github.com/ngokevin.png","language":"JavaScript","readme":"react-file-reader-input\n=======================\n\nReact file input component for complete control over styling and abstraction\nfrom file reading.\n\n## \\\u003cFileReaderInput as={dataFormat} onChange={handler} {...props}/\\\u003e\n\n- **as** (string): what format the FileReader should read the\n  file as (i.e., ```buffer```, ```binary```, ```url```, ```text```). Defaults\n  to ```url```.\n- **children** (element): if children is passed into\n  FileReaderInput, then the component will hide the native file input and\n  instead display ```children```. Whenever the custom ```children``` are\n  clicked, the component will trigger the native file input prompt. This\n  allows complete control over styling an display.\n- **onChange** (function): callback ```function(event, results)```.\n  Results will be an array of arrays, the size of which depending on how many\n  files were selected. Each result will be an array of two items:\n    - *progressEvent*: ```result[0]``` is a\n      [ProgressEvent](https://developer.mozilla.org/docs/Web/API/ProgressEvent)\n      object. You can retrieve the raw results at\n      ```progressEvent.target.result``` among other things.\n    - *file*: ```result[1]``` is a\n      [File](https://developer.mozilla.org/docs/Web/API/File) object. You can\n      retrieve the file name at ```file.name``` among other things.\n\nAll other props on ```FileReaderInput``` will be passed down to the native file\ninput.\n\n### Usage\n\n```js\nimport React from 'react';\nimport FileReaderInput from 'react-file-reader-input';\n\n\nclass MyComponent extends React.Component {\n  handleChange = (e, results) =\u003e {\n    results.forEach(result =\u003e {\n      const [e, file] = result;\n      this.props.dispatch(uploadFile(e.target.result));\n      console.log(`Successfully uploaded ${file.name}!`);\n    });\n  }\n  render() {\n    return (\n      \u003cform\u003e\n        \u003clabel htmlFor=\"my-file-input\"\u003eUpload a File:\u003c/label\u003e\n        \u003cFileReaderInput as=\"binary\" id=\"my-file-input\"\n                         onChange={this.handleChange}\u003e\n          \u003cbutton\u003eSelect a file!\u003c/button\u003e\n        \u003c/FileReaderInput\u003e\n      \u003c/form\u003e\n    );\n  }\n}\n```\n","funding_links":[],"categories":["UI Components","Uncategorized","Demos","Javascript","\u003csummary\u003eUI Components\u003c/summary\u003e"],"sub_categories":["Miscellaneous","Uncategorized","React UI"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fngokevin%2Freact-file-reader-input","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fngokevin%2Freact-file-reader-input","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fngokevin%2Freact-file-reader-input/lists"}