Skip to content

Instantly share code, notes, and snippets.

@gitumarkk
Created November 16, 2020 15:55
Show Gist options
  • Select an option

  • Save gitumarkk/8127a87d2dbe2aef96c495f8d3f633e7 to your computer and use it in GitHub Desktop.

Select an option

Save gitumarkk/8127a87d2dbe2aef96c495f8d3f633e7 to your computer and use it in GitHub Desktop.
//...
export default function SelectFile () {
const dispatch = useDispatch();
const pickVideo = () => {
const options = {
title: 'Upload Video',
takePhotoButtonTitle: 'Record video',
chooseFromLibraryButtonTitle: 'Choose From Library',
mediaType: 'video',
storageOptions: {
skipBackup: true,
waitUntilSaved: true,
},
};
ImagePicker.showImagePicker(options, (response) => {
if (!response.didCancel && !response.error) {
const path = Platform.select({
android: { "value": response.path },
ios: { "value": response.uri }
}).value;
dispatch(fileUpload({ local_path: path }));
}
});
};
return (
<Button
onPress={pickVideo}
title="Upload"
/>
)
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment