2016-08-31 27 views
2

私は反応して、アンドロイドで開発するネイティブを使用します。そして私は、サーバーへのファイルや写真をアップロードしたい.AND私は反応するネイティブ・ファイル・アップローダーを使用し、私はエラーを得た:写真をアップロードする方法ネイティブandroidに反応する

[未定義のは(「 を評価する目的ではない_reactNative.NativeModules.FileUploader.upload ')]、Cannot read property 'upload' of undefined2

ご協力ありがとうございました! 怒鳴るは私のコードです:

import React from 'react'; 
    import { 
    View, 
    Text, 
    Image, 
    StyleSheet, 
    TouchableOpacity, 
    Platform, 
    DeviceEventEmitter 
    } from 'react-native'; 

import Icon from 'react-native-vector-icons/FontAwesome' 
import FileUploader from 'react-native-file-uploader' 

const settings = { 
/* uri, 
uploadUrl, 
method, // default to 'POST' 
fileName, // default to 'yyyyMMddhhmmss.xxx' 
fieldName, // default to 'file' 
contentType, // default to 'application/octet-stream' 
data: { 
// extra fields to send in the multipart payload 
}*/ 
    }; 

export default class NewDishView extends React.Component{ 
constructor(props){ 
    super(props) 
    this.state={ 
     avatarSource:'./src/images/support.png' 
    } 
} 
goBack(){ 
    this.props.navigator.pop(); 
} 

render(){ 
    return (
     <View> 
      <View style={styles.header}> 

       <TouchableOpacity onPress={()=>this.goBack()} style={styles.back}> 
        <Icon style={styles.backIcon} name="chevron-left" /> 
       </TouchableOpacity> 

       <View style={{flex:1}}>    
        <Text style={styles.title}>Create new dish</Text> 
       </View> 
      </View> 

      <TouchableOpacity onPress={ 
       FileUploader.upload(settings, (err, res) => { 
        // handle result 
       }, (sent, expectedToSend) => { 
        // handle progress 
       }) 
      }> 
       <Text>upload</Text> 
      </TouchableOpacity> 
     </View> 
    ) 
} 
} 

const styles = StyleSheet.create({ 

header:{ 
    flexDirection:'row', 
}, 
back:{ 
    paddingLeft:10, 
    paddingTop:5, 
    width:25, 
}, 
backIcon:{ 
    color:'#000', 
    fontSize:20, 
}, 
title:{ 
    fontSize:20, 
    textAlign:'center', 
}, 
}) 

答えて

関連する問題