Coder Social home page Coder Social logo

simonjodet / dropbox-session-upload Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chris-burgin/dropbox-session-upload

0.0 1.0 0.0 142 KB

Node wrapper around the dropbox upload session API to help concurrently upload files over 150mb to dropbox.

JavaScript 100.00%

dropbox-session-upload's Introduction

Dropbox Session Upload

About

Dropbox Session Upload provides a wrapper around the Dropbox Node Package. Session Uploading via the Dropbox API is used for files that are large than 150mb. This section of the API can be complicated and this package hopes to provide a clean wrapper around this complicated API. This wrapper also supports concurrent file uploading out of the box.

Requirements

  • Node 8.3.0 or greater

Installation

npm install dropbox_session_upload

Usage

Upload Files Basic

This Example can be found in /examples/simple.js

// import modules
const fs = require("fs")
const {upload} = require("dropbox_session_upload")

// setup files to upload
const files = [
  {
    file: fs.createReadStream("./datafile.txt"),
    saveLocation: "/datafile1.txt"
  },
  {
    file: fs.createReadStream("./datafile.txt"),
    saveLocation: "/datafile2.txt"
  },
  {
    file: fs.createReadStream("./datafile.txt"),
    saveLocation: "/datafile3.txt"
  }
]

// upload the files
upload(files, process.env.DROPBOXTOKEN, true /* debug mode, defaults to false */)
  .catch(error => console.log(error))
  .then(() => console.log("Done Uploading!"))

Upload with Progress Tracking

This Example can be found in /examples/progressTracking.js

Adding progress tracking is simple, but due to the dropbox api progress will only be updated every 8mb. This is the size of chunks this packages uploads at once. So you will find that progress jumps in 8mb chunks. While annoying it can still be helpful to know where your file is at in the upload process.

// import modules
const fs = require("fs")
const { upload, progress } = require("dropbox_session_upload")

// setup files to upload
const files = [
  {
    file: fs.createReadStream("./datafile.txt"),
    saveLocation: "/datafile1.txt",
    id: "1" // required for progress
  },
  {
    file: fs.createReadStream("./datafile.txt"),
    saveLocation: "/datafile1.txt",
    id: "2" // required for progress
  },
  {
    file: fs.createReadStream("./datafile.txt"),
    saveLocation: "/datafile1.txt",
    id: "3" // required for progress
  }
]

// upload the files
upload(files, process.env.DROPBOXTOKEN)
  .catch(error => console.log(error))
  .then(() => console.log("Files Done!"))

// listen for updates to the progress
// this will return `id` and `percentage`
progress(data => console.log(data))

Things to note when uploading

  • This library will automatically strip out the following characters from saveLocation * | & ! @ # $ % ^ * ( ) [ ] { } | - _ = + < > ' " < > to comply with dropbox file name requirements.

dropbox-session-upload's People

Contributors

chris-burgin avatar simonjodet avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.