2

I want to read a file mp3 file at react-native like this, how can i do.

<Buffer 75 64 e5 be 9b 6d e4 84 97 a3 10 61 50 07 13 72 b9 ca 95 56 a0 42 4b e7 23 ea 6a 09 cb 9c 4c 3f ac 9f 70 b8 f8 56 89 d8 2e 09 79 60 42 04 d0 91 22 dd ... 52499 more bytes>
Aung Htet Paing
  • 121
  • 1
  • 1
  • 9

2 Answers2

0

you can read file by using react-native-fs

Install react-native-fs by

yarn add react-native-fs

Code:

var RNFS = require('react-native-fs');

const file=await RNFS.readFile(filePath);
console.log(file); // <Buffer 75 64 e5 be .....
Muhammad Numan
  • 23,222
  • 6
  • 63
  • 80
0

You can define your type while reading from file like below also if the file is large, you should consider using readStream instead.

RNFetchBlob.fs.readFile(PATH_TO_READ, 'base64')
.then((data) => {
  // handle the data ..
})

Edit: I think this answer will help you in this matter

react-native-fs: How to read local images (Get base64 of local file)

Waheed Akhtar
  • 3,110
  • 1
  • 16
  • 30