Convert image path to blob react native

后端 未结 4 1912
隐瞒了意图╮
隐瞒了意图╮ 2021-02-19 04:21

Problem

I am trying to create an app with react native and firebase. One of the features I would like for this app is the ability to upload images. I

4条回答
  •  南方客
    南方客 (楼主)
    2021-02-19 05:02

    If you are using expo (>=26), then you can do it easily with the following lines of code.

    uploadImage = async(imageUri) => {
      const response = await fetch(imageUri);
      const blob = await response.blob();
      var ref =   firebase.storage().ref().child("image.jpg");
      return ref.put(blob);
    }
    

    Reference: https://youtu.be/KkZckepfm2Q

提交回复
热议问题