I am trying a read a Image File using react-native-fs
in react-native.
Below is my generator function in saga.js:
function* uploadCardLogo(logo, userId) {
console.log("uploading card logo"); //being logged
const storageRef = firebase.storage().ref('${userId}').child("mycards/logos/");
console.log("storage ref fetched " + logo.uri); //being logged
const cardLogo = yield call(RNFS.readFile, logo.uri); // Not throwing any errors
console.log("reading file done") // Not being logged
const logoStorageUrl = yield call([storageRef, storageRef.put], cardLogo);
console.log("Logo has been update = ${logoStorageUrl}");
return logoStorageUrl;
}
As you can see, I am not able to read the Image file nor am I getting any errors, Can anyone please tell me what I am doing wrong?
EDIT:
Below is my function from which uploadCardLogo
is being called:
function* uploadCard(action) {
console.log("about to upload card");
console.log(action.card);
try{
const userId = firebase.auth().currentUser.uid;
const database = firebase.database();
const logoStorageUrl = yield call(uploadCardLogo, action.card.logo, userId);
const ref = database.ref('users/'+userId+'/myCards');
const result = yield call([ref, ref.set], action.card);
console.log("Card Added To Realtime Database");
yield put({type: CARD_UPLOADED, card: action.card});
console.log("about to update app state");
}
catch(error) {
const error_message = {code: error.code, message: error.message};
yield put({type: CARD_UPLOAD_ERROR, error: error_message})
}
}