npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dropbox-streaming-upload

v1.0.4

Published

Streaming uploads to dropbox v2 api

Downloads

17

Readme

dropbox-streaming-upload

Streaming uploads for dropbox api v2

Official js sdk by dropbox lacks streaming upload feature. This package provide just that missing feature, nothing else.

Installation

npm install --save dropbox-streaming-upload

Supported features

  • Simple basic upload
  • Upload session for bigger files (dropbox requires upload session for files bigger than 150mb. Though you can choose it with files of any size)
  • Ability to cancel upload

Usage

const upload = require('dropbox-streaming-upload').default
upload(options).then(function(successMetadata) {

}, function(error) {

})

Options

  • access_token: Dropbox access token.
  • readable_stream: Readable stream to upload.
  • file_size: Total size of upload in bytes. Since we just have the readable stream we need size information separately.
  • destination: Destination path in dropbox where to upload the file (full file path: ie, if you are uploading roses.jpg to /weeds/ folder, then "/weeds/roses.jpg").
  • forced_chunked_upload: By default library will use upload session if file_size is greater than 150mb. If you set this to true, then it will force upload session regardless of file_size.
  • chunk_size: By default library will use 5mb chunk while using chunked upload. You can override it here (in bytes).
  • mute: See dropbox documentation for /upload or /upload_session/finish. Default is false.
  • autorename: See dropbox documentation for /upload or /upload_session/finish. Default is true.
  • mode: See dropbox documentation for /upload or /upload_session/finish. Default is "add".
  • client_modified: See dropbox documentation for /upload or /upload_session/finish.

Cancelling upload

const upload = require('dropbox-streaming-upload').default
const options = {
    access_token: 'token',
    readable_stream: someStream,
    file_size: totalSize,
    destination: '/mypath/myfile.ext',
}
upload(options).then(function(successMetadata) {

}, function(error) {
    if (error.message === 'user_aborted') {
        // you cancelled the upload below
    }
})

// when you want to cancel it (before upload is done/failed)
// cancel function is added to your options object by library
// calling cancel function after upload is done/failed has no effect
options.cancel()

Unit testing

  • clone this repository
  • run
npm install
  • copy ./sample_test_data.json to ./tests/test_data.json
  • fill in "access_token"
  • fill in "unitTestBaseFolder". Unit test will create a tmp folder in that folder and upload files inside that (tmp folder will be removed in the end)
  • update "uploads" array as needed. structure of uploads array item:
{
    "localFilePath": "localfilepath.ext",
    "destination": "./relative/to/tmp/folder/risingearth.jpg",
    "forced_chunked_upload": false,
    "chunk_size": 5e+6
}
  • forced_chunked_upload and chunk_size are optional
  • run
npm test