我在从相机胶卷或我的API上传图片时遇到问题.这是我目前使用的代码.我能够从相机胶卷和相机中获取图像数据.我只是遇到了将数据发布到服务器的问题.我不知道我在哪里感到困惑.
import React, { Component } from 'react';
import {
Text,
View,
PixelRatio,
TouchableOpacity,
Image,
Platform,
NativeModules,
DeviceEventEmitter
} from 'react-native';
import { connect } from 'react-redux';
import ImagePicker from 'react-native-image-picker';
import { captureProflieAvitar } from '../../actions';
var RNUploader = NativeModules.RNUploader;
class NewCamera extends Component {
state = {
avatarSource: null,
imgBase64: []
}
componentDidMount() {
// upload progress
DeviceEventEmitter.addListener('RNUploaderProgress', (data) => {
const bytesWritten = data.totalBytesWritten;
const bytesTotal = data.totalBytesExpectedToWrite;
const progress = data.progress;
console.log(bytesWritten, bytesTotal);
console.log( "upload progress: …Run Code Online (Sandbox Code Playgroud)