- Notifications
You must be signed in to change notification settings - Fork19
A plugin for file upload on react-native
License
NotificationsYou must be signed in to change notification settings
booxood/react-native-file-upload
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
React Native latest version had support file upload, the package isdeprecated, detail see#4#7.
A file upload plugin for react-native written by Objective-C.
- Support to upload multiple files at a time
- Support to files and fields
npm install react-native-file-upload --save- In XCode, in the project navigator, right click
your project➜Add Files to [your project's name] - Go to
node_modules➜react-native-file-uploadand addFileUpload.m - Run your project (
Cmd+R)
All you need is to export modulevar FileUpload = require('NativeModules').FileUpload; and direct invokeFileUpload.upload.
'use strict';varReact=require('react-native');varFileUpload=require('NativeModules').FileUpload;var{ AppRegistry, StyleSheet, Text, View,}=React;varFileUploadDemo=React.createClass({componentDidMount:function(){varobj={uploadUrl:'http://127.0.0.1:3000',method:'POST',// default 'POST',support 'POST' and 'PUT'headers:{'Accept':'application/json',},fields:{'hello':'world',},files:[{name:'one',// optional, if none then `filename` is used insteadfilename:'one.w4a',// require, file namefilepath:'/xxx/one.w4a',// require, file absoluete pathfiletype:'audio/x-m4a',// options, if none, will get mimetype from `filepath` extension},]};FileUpload.upload(obj,function(err,result){console.log('upload:',err,result);})},render:function(){return(<Viewstyle={styles.container}><Textstyle={styles.welcome}> Welcome to React Native!</Text></View>);}});varstyles=StyleSheet.create({container:{flex:1,justifyContent:'center',alignItems:'center',backgroundColor:'#F5FCFF',},welcome:{fontSize:20,textAlign:'center',margin:10,},});AppRegistry.registerComponent('FileUploadDemo',()=>FileUploadDemo);
MIT
About
A plugin for file upload on react-native
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.