@anarock/react-native-cloudinary
v1.0.0-beta.0
Published
A react native module for uploading files to cloudinary
Downloads
25
Keywords
Readme
react-native-cloudinary
Getting started
$ npm install react-native-cloudinary --save
Mostly automatic installation
$ react-native link react-native-cloudinary
Manual installation
Android
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.pranjal.RNCloudinaryPackage;
to the imports at the top of the file - Add
new RNCloudinaryPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-cloudinary' project(':react-native-cloudinary').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-cloudinary/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-cloudinary')
Usage
import RNCloudinary from 'react-native-cloudinary';
try {
const uploadRequest = await RNCloudinary
.init(filePath)
.setOptions(options) // Set cloudinary options (Optional)
.setPolicy(policy) // Set upload policy options (Optional)
.setListeners({
onStart: () => { // Do something on upload start },
onProgress: (bytes, totalBytes) => { // Show upload progress },
onSuccess: () => { // Do something on success },
onError: (e) => { // Handle upload time error }
})
.dispatch()
} catch (e) {
// Handle init error
}
uploadRequest.clearListeners() // Clears listeners