How to download an image with CRNA

  • If you are building app with Expo, to down load an image to Galary of mobile. You can use FileSystem from expo

    const fileUri = FileSystem.documentDirectory + fileName;
    .then(({ uri }) => {
        console.log('Finished downloading to ', uri);
    • fileName: name of image, u can get name from imageUrl or any name
    • imageUrl: link url contains the image
    • fileUri: is uri contains the image after download

    After download, will be returned an uri that save the image. You should check download successfully with getInfoAsync image, if return exists not equal 0.

    To save the image into Galary of mobile, you should do this

    import { CameraRoll } from "react-native"
      .then((res) => {
        console.log('res ', res)
        CameraRoll.saveToCameraRoll(uri, 'photo')
    ca  })

    Done. Open Galary on mobile to check
    Nguồn: Viblo

Hãy đăng nhập để trả lời

Có vẻ như bạn đã mất kết nối tới LaptrinhX, vui lòng đợi một lúc để chúng tôi thử kết nối lại.