Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

File upload code sample for React Native for ConnectyCube platform

This README introduces a code sample for ConnectyCube platform on how to upload files from React Native to ConnectyCube Storage cloud.

Project contains the following features implemented:

  • User login to ConnectyCube platform
  • Possibility to make photo via device camera
  • Possibility to pick images from device gallery
  • Upload the chosen image file to ConnectyCube Storage cloud

Quick review

Install Expo Client application from App Store or Google Play and follow by link to project published at Expo - RNUploadFiles

Quick start and develop

Quick start React Native app: install npm install -g expo-cli and run npm start from the root of this folder.

How to build iOS/Android project

Install npm install -g expo-cli if did not it before and run npm eject from the root of this folder.

Read more about Expo and about React Native getting started guide.

Upload file to ConnectyCube storage without using Expo SDK

Possible to use React Native Image Crop Picker or React Native Image Picker

import React from 'react'
import ConnectyCube from 'connectycube-reactnative'
import { View, Button, Image } from 'react-native'
import ImagePicker from 'react-native-image-crop-picker';

const auth = { appId: 0, authKey: '...', authSecret: '...', }
const conf = { debug: { mode: 1 } }
const user = { email: '...', password: '...' }

export default class App extends React.Component {
  state = { imageUri: null }

  componentWillMount() {
    ConnectyCube.init(auth, conf)

    ConnectyCube.createSession(user, (error, session) => {
      if (session) {
      } else {

    // or ImagePicker.openPicker()
      cropping: true,
    }).then(image => {
      const data = {
        uri: image.path,
        size: image.size,
        name: image.path.split('/').pop(),
        type: image.mime
        file: data,
        size: data.size,
        type: data.type,
        public: false
      }, (error, result) => {
        if (result) {
          const imageURL =
          // const imageURL = - if public = true

          this.setState({ imageUri: imageURL })
        } else {

  render() {
    const { imageUri } = this.state

    return (
      <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
        <View style={{ marginBottom: 20 }}>
            title="Pick from Camera and upload"
            onPress={() => this.pickImageAndUpload()}
        { imageUri &&
            source={{ uri: imageUri }}
            style={{ width: 300, height: 300 }}

Can't build yourself?

Got troubles with building Cordova code sample? Just create an issue at Issues page - we will create the sample for you. For FREE!

You can’t perform that action at this time.