【问题标题】:How to get the Image URL of rct-image-store to upload image through api如何通过api获取rct-image-store的Image URL上传图片
【发布时间】:2016-03-30 17:34:51
【问题描述】:

如何从 rct-image-store 获取图片 url?我使用 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-image-store://0

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

【问题讨论】:

  • 你找到解决办法了吗?

标签: react-native


【解决方案1】:

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>
            );
        },

});

【讨论】:

  • 您能描述一下您遇到的问题以及您预期的结果吗?
  • 请再次检查问题。这显示了如何裁剪图像,它不处理如何将其上传到服务器。
猜你喜欢
  • 2020-02-20
  • 2018-07-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-09-05
  • 1970-01-01
  • 2019-02-16
  • 2016-04-16
相关资源
最近更新 更多