Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 28463

How to set headers downloading a file using React Native and react-native-fs?

$
0
0

In order to download an asset an Authorization header needs to be set when using react-native-fs with React Native.

Following the documentation the header is set as such:

  const options = {
    headers: {
      Authorization: `Bearer ${accessToken}`,
    },
    fromUrl: url,
    toFile: path,
  };

  // const permission = await insurePermissions();

  const task = RNFS.downloadFile(options);

It works perfect in iOS however Android, using an emulator running either Android 6, 8, 9, or 10, the header isn't being sent so the server is instead returning a different asset with error because the user isn't being authenticated.

How is the Authentication header set in Android with react-native-fs?


Viewing all articles
Browse latest Browse all 28463

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>