when uploading a video on, how to get its size.
I can set a limit to the duration but not the size.
I used this module
react-native-image-picker
this is the code used:
import ImagePicker from 'react-native-image-picker';
ImagePicker.showImagePicker(options, response => {
this.setState({ loading: false });
if (response.didCancel) {
console.log('User cancelled video picker');
} else if (response.error) {
console.log('ImagePicker Error: ', response.error);
} else {
let path = '';
if (Platform.OS === 'android') {
path = response.path;
} else {
path = response.uri;
}
const videoExtentionPos = path.lastIndexOf('.');
const videoExtention = path.substring(videoExtentionPos + 1);
this.setState({
fields: {
...fields,
posts_video: {
uri: response.uri,
type: `video/${videoExtention}`,
name: `video.${videoExtention}`
}
}
});
} });