Skip to content

WebNinjaDeveloper.com

Programming Tutorials




Menu
  • Home
  • Youtube Channel
  • Official Blog
  • Nearby Places Finder
  • Direction Route Finder
  • Distance & Time Calculator
Menu

React.js Dropbox File Upload Using Dropbox File Chooser API and react-dropbox-chooser Library

Posted on December 15, 2022

 

 

Welcome folks today in this blog post we will be uploading files to dropbox in react.js using dropbox file chooser api and react-dropbox-chooser library in javascript. All the full source code of the application is shown below.

 

 

Get Started

 

 

In order to get started you need to make a new react.js project using the below command as shown below

 

 

npx create-react-app sampleproject

 

 

cd sampleproject

 

 

And now you need to install the below libraries using the below command as shown below

 

 

npm i react-dropbox-chooser

 

 

npm i prop-types

 

 

And after that you need to go to dropbox developer website and get your app key credentials as shown below

 

 

 

 

 

 

 

 

 

 

And now basically you need to copy paste your App key and now you need to add your domain inside the domains section of the dropbox app as shown below

 

 

 

 

And after that we just need to make the App.js file and copy paste the following code

 

 

JavaScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import React, { useState } from "react";
import "./styles.css";
import DropboxChooser from 'react-dropbox-chooser'
 
const APP_KEY="4r6uo01trb8misy"
 
export default function App() {
  const [url,setUrl] = useState("")
  function handleSuccess(files){
    setUrl(files[0].thumbnailLink)
    console.log(url)
  }
  return (
    <div className="App">
      <h1 style={{textAlign:"center"}}>Upload Or Choose Files to DropBox</h1>
      <br/><br/>
    <div className="container">
      <DropboxChooser appKey={APP_KEY}
                      success={handleSuccess}
                      cancel={() => console.log('closed')}
                      multiselect={true}
                      >
        <button>Upload or Choose Files</button>
        <div className="dropbox"></div>
        <br/><br/>
        <img src={url} width="200" height="200" alt=""/>
      </DropboxChooser>
    
    </div>
    </div>
  );
}

 

 

As you can see in the above code you need to replace your own dropbox app key and then basically we are importing the dropbox file chooser api library and then we have the button if we click it then the dropbox filechooser will be shown where the user can select the files or upload the files to dropbox as shown below

 

 

 

Recent Posts

  • Android Kotlin Project to Load Image From URL into ImageView Widget
  • Android Java Project to Make HTTP Call to JSONPlaceholder API and Display Data in RecyclerView Using GSON & Volley Library
  • Android Java Project to Download Youtube Video Thumbnail From URL & Save it inside SD Card
  • Android Java Project to Embed Google Maps & Add Markers Using Maps SDK
  • Android Java Project to Download Random Image From Unsplash Using OkHttp & Picasso Library & Display it
  • Angular
  • Bunjs
  • C#
  • Deno
  • django
  • Electronjs
  • java
  • javascript
  • Koajs
  • kotlin
  • Laravel
  • meteorjs
  • Nestjs
  • Nextjs
  • Nodejs
  • PHP
  • Python
  • React
  • ReactNative
  • Svelte
  • Tutorials
  • Vuejs




©2023 WebNinjaDeveloper.com | Design: Newspaperly WordPress Theme