How to use the expo-file-system.EncodingType function in expo-file-system

To help you get started, we’ve selected a few expo-file-system examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bytefury / crater-mobile / src / components / FilePicker / index.js View on Github external
const { mediaType = 'Images' } = this.props

        let result = await ImagePicker.launchImageLibraryAsync({
            mediaTypes: ImagePicker.MediaTypeOptions[mediaType],
            // mediaTypes: ImagePicker.MediaTypeOptions.All,
            allowsEditing: mediaType === 'Images' ? true : false,
            base64: true,
            quality: 1,
        });

        if (!result.cancelled) {
            const { onChangeCallback, input: { onChange } } = this.props
            this.setState({ image: result.uri });

            FileSystem.readAsStringAsync(result.uri, {
                encoding: FileSystem.EncodingType.Base64
            }).then((base64) => {
                const res = { ...result, base64 }
                onChangeCallback(res)
                this.onToggleLoading()
            })
                .catch(error => {
                    console.error(error);
                });
        }
        else {
            this.onToggleLoading()
        }
    };