问题:
在我的本机应用程序中,我使用了rn-fetch-blob fs.readstream。但是在读取流stream.onEnd后不会触发。
我已经这样使用了。
options = {
title: strings('picker.q-v-pick'),
takePhotoButtonTitle: strings('picker.tphoto'),
chooseFromLibraryButtonTitle: strings('picker.cgallery'),
cancelButtonTitle: strings('picker.cancel'),
mediaType: 'video',
durationLimit: question.question.duration,
videoQuality: Platform.OS === 'android' ? 'medium' : 'low',
storageOptions: {
skipBackup: true,
path: 'images',
},
};
ImagePicker.launchCamera(options, (response) => {
if (response.didCancel) {
console.log('User cancelled image picker');
} else if (response.error) {
console.log('ImagePicker Error: ', response.error);
} else if (response.customButton) {
console.log('User tapped custom button: ', response.customButton);
} else {
RNFetchBlob.fs.readStream(response.path, 'base64').then((stream) => {
let bitData = '';
stream.open();
stream.onData((chunk) => {
// console.log(chunk);
bitData += chunk;
});
stream.onEnd(() => {
console.log('HIIi');
console.log(bitData, 'uuu');
});
// response['data'] = data;
// response['type'] = 'mp4';
// response['fileName'] = 'videomulti.mp4';
// setFileObject(response);
});
}
});
stream.open和onData函数被触发,但是stream.OnEnd不触发,有人可以帮助我解决此问题吗?我对此一无所知。非常感谢。