<legend id='P5te6'><style id='P5te6'><dir id='P5te6'><q id='P5te6'></q></dir></style></legend>
    <i id='P5te6'><tr id='P5te6'><dt id='P5te6'><q id='P5te6'><span id='P5te6'><b id='P5te6'><form id='P5te6'><ins id='P5te6'></ins><ul id='P5te6'></ul><sub id='P5te6'></sub></form><legend id='P5te6'></legend><bdo id='P5te6'><pre id='P5te6'><center id='P5te6'></center></pre></bdo></b><th id='P5te6'></th></span></q></dt></tr></i><div id='P5te6'><tfoot id='P5te6'></tfoot><dl id='P5te6'><fieldset id='P5te6'></fieldset></dl></div>

      <small id='P5te6'></small><noframes id='P5te6'>

        <bdo id='P5te6'></bdo><ul id='P5te6'></ul>

      <tfoot id='P5te6'></tfoot>
    1. 如何将图像 URI 转换为字节博览会

      How Do I Convert Image URI into Byte Expo(如何将图像 URI 转换为字节博览会)
      <legend id='716Wv'><style id='716Wv'><dir id='716Wv'><q id='716Wv'></q></dir></style></legend>

      <small id='716Wv'></small><noframes id='716Wv'>

            • <bdo id='716Wv'></bdo><ul id='716Wv'></ul>

                <i id='716Wv'><tr id='716Wv'><dt id='716Wv'><q id='716Wv'><span id='716Wv'><b id='716Wv'><form id='716Wv'><ins id='716Wv'></ins><ul id='716Wv'></ul><sub id='716Wv'></sub></form><legend id='716Wv'></legend><bdo id='716Wv'><pre id='716Wv'><center id='716Wv'></center></pre></bdo></b><th id='716Wv'></th></span></q></dt></tr></i><div id='716Wv'><tfoot id='716Wv'></tfoot><dl id='716Wv'><fieldset id='716Wv'></fieldset></dl></div>
                  <tbody id='716Wv'></tbody>
                <tfoot id='716Wv'></tfoot>

                本文介绍了如何将图像 URI 转换为字节博览会的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在使用 expo-image-picker 上传图片.但问题是我想通过 WebAPI 以字节的形式将图像发送到服务器.那么如何将图像 URI 转换为字节呢?如果有人有这方面的经验,请分享.

                I'm uploading image using expo-image-picker. but the issue is I want to send the image to the server through WebAPI in the form of Byte. So how can I convert the image URI into Byte? if anyone have experience on it so kindly share.

                 componentDidMount() {
                        this.getPermissionAsync();
                    }
                    getPermissionAsync = async () => {
                        if (Constants.platform.ios) {
                            const { status } = await Permissions.askAsync(Permissions.CAMERA_ROLL);
                            if (status !== 'granted') {
                                alert('Sorry, we need camera roll permissions to make this work!');
                            }
                        }
                    };
                    _pickImage = async () => {
                        try {
                            let result = await ImagePicker.launchImageLibraryAsync({
                                allowsEditing: true,
                                aspect: [4, 3],
                            });
                            console.log(result);
                
                            if (!result.cancelled) {
                                this.setState({ image: result.uri });
                            }
                        } catch (e) {
                            console.log(e);
                        }
                    };
                render() {
                        return (
                            <View>
                                <Card>
                                    <CardItem>
                                        <Body>
                                            <Button block primary onPress={() => this._pickImage()}>
                                                <Text>Add Activity</Text>
                                            </Button>
                                            {this.state.image && <Image source={{ uri: this.state.image }} style={{ width: 200, height: 200 }} /> }
                                        </Body>
                                    </CardItem>
                                </Card>
                            </View>
                        );
                    }
                

                世博小吃

                推荐答案

                你可以这样做:

                import { Buffer } from "buffer";
                
                _pickImage = async () => {
                  try {
                    let result = await ImagePicker.launchImageLibraryAsync({
                      base64: true,
                      allowsEditing: true,
                      aspect: [4, 3],
                    });
                
                    if (!result.cancelled) {
                      let imageByte = new Buffer(result.base64, "base64");
                
                      this.setState({ image: result.uri });
                    }
                  } catch (e) {
                      console.log(e);
                  }
                };
                

                注意:您将需要 buffer 包.

                NOTE: You will need buffer package.

                这篇关于如何将图像 URI 转换为字节博览会的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                在开发JS过程中,会经常遇到两个小数相运算的情况,但是运算结果却与预期不同,调试一下发现计算结果竟然有那么长一串尾巴。如下图所示: 产生原因: JavaScript对小数运算会先转成二进制,运算完毕再转回十进制,过程中会有丢失,不过不是所有的小数间运算会
                问题描述: 在javascript中引用js代码,然后导致反斜杠丢失,发现字符串中的所有\信息丢失。比如在js中引用input type=text onkeyup=value=value.replace(/[^\d]/g,) ,结果导致正则表达式中的\丢失。 问题原因: 该字符串含有\,javascript对字符串进行了转
                Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
                quot;Each child in an array should have a unique key propquot; only on first time render of page(“数组中的每个孩子都应该有一个唯一的 key prop仅在第一次呈现页面时)
                CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)
                Ordinals in words javascript(javascript中的序数)
                • <i id='9Vur7'><tr id='9Vur7'><dt id='9Vur7'><q id='9Vur7'><span id='9Vur7'><b id='9Vur7'><form id='9Vur7'><ins id='9Vur7'></ins><ul id='9Vur7'></ul><sub id='9Vur7'></sub></form><legend id='9Vur7'></legend><bdo id='9Vur7'><pre id='9Vur7'><center id='9Vur7'></center></pre></bdo></b><th id='9Vur7'></th></span></q></dt></tr></i><div id='9Vur7'><tfoot id='9Vur7'></tfoot><dl id='9Vur7'><fieldset id='9Vur7'></fieldset></dl></div>
                    <tbody id='9Vur7'></tbody>
                    <bdo id='9Vur7'></bdo><ul id='9Vur7'></ul>
                    <legend id='9Vur7'><style id='9Vur7'><dir id='9Vur7'><q id='9Vur7'></q></dir></style></legend>

                    <small id='9Vur7'></small><noframes id='9Vur7'>

                        • <tfoot id='9Vur7'></tfoot>