如何获取rct-image-store的图像URL以通过api上传图像

时间:2015-12-24 08:58:46

标签: react-native

如何从rct-image-store获取图片网址?我使用ImageEditingManager裁剪图像,它返回rct-image-store:// 0。现在我需要将此图像上传到服务器。如何获取图像的URL以便我可以上传它?

这是我使用的代码

  ImageEditingManager.cropImage(
        photoURI,
        transformData,
        (croppedImageURI) => {
          console.log('crop success', croppedImageURI);
        },
        (cropError) => console.log('cropMyError', cropError)
      );
    },
    (error) => undefined,
  );

croppedImageURI记录为

  

RCT-图像店内:// 0

如何获取此图像的网址,以便将其上传到api服务器?

1 个答案:

答案 0 :(得分:-5)



var testDemo = React.createClass({
    getInitialState() {
            return {
                imageURISource: {
                    uri: 'http://facebook.github.io/react/img/logo_og.png'
                }
            }
        },

        render: function() {
            return (
                <View style={styles.container}>
                <Image
                    style={{height:250,width:300, borderColor: '#f099f0',borderRadius:3}}
                    source= {this.state.imageURISource}
                    />

                ImageEditingManager.cropImage(
                        photoURI,
                        transformData,
                        (croppedImageURI) => {
                                console.log('crop success', croppedImageURI);
              
                                //get croppedImageURI and set, it will update Image
                                this.setState({imageURISource: {uri:croppedImageURI}})
                                
                        },
                        (cropError) => console.log('cropMyError', cropError)
                );
                    
            </View>
            );
        },

});
&#13;
&#13;
&#13;