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-autoupload

v1.0.0

Published

Monitors local files for changes and automatically uploads them to Dropbox.

Downloads

5

Readme

dropbox-autoupload

This script provides a simple, barebones way of automatically uploading files to Dropbox on modification. It watches the specified list of files for changes and initiates an upload when any occur.

I use it to periodically back up the world file for the Terraria server I run on a Raspberry Pi, which does not have a native Dropbox client.

Getting Started

First, install the package with npm i -g dropbox-autoupload. Then you will need to obtain an access token to authenticate to Dropbox and create a configuration file to specify the access token and a list of files to watch.

Access Token

You can get an access token for your Dropbox account by visiting https://www.dropbox.com/developers/apps, clicking "Create App," and selecting "Dropbox API" and the access level you want. I recommend only allowing access to an app folder rather than full Dropbox access, but that decision is personal preference. I promise my code won't steal your files. ;-)

Finally, once your app is created in Dropbox, click on it. In the "OAuth 2" section, under "Generated access token," click the "Generate" button and copy the token it generates.

Configuration File

Once you have your access token, you can create your configuration file. This file is JSON format with only a few fields. Here is an example configuration file:

{
	"accessToken": "Your_access_token_here",
	"minUpdateInterval": 120,
	"files":
	[
		{"localPath": "index.js", "remotePath": "/index.js"}
	]
}

This file can be called whatever you want. dropbox-autoupload can take a configuration filename as a command-line argument, but if no file is specified that way, it will look for a file called autoupload.json in the current working directory.

  • accessToken is a string containing the Dropbox access token from the above step.
  • minUpdateInterval is an optional number which, if specified, is the smallest amount of time between uploads of any file. If a file is updated more frequently, it will not be re-uploaded until at least this much time has passed. This interval is specified in seconds.
  • files is an array of objects specifying the locations of the files to watch and upload.
    • localPath specifies where each file is located on the local device.
    • remotePath specifies where to upload each file to in Dropbox. This is relative to the folder your app has access to.

Running

Just execute dropbox-autoupload from a terminal, specifying the name of your configuration file if it isn't autoupload.json. It will begin watching the files specified for any changes and uploading them to your Dropbox account as needed. You should be able to safely end the process at any time, although the behavior is dependent on the Dropbox SDK if an upload is in progress.

Known Issues

This will not handle files greater than 150 MB in size. I may add support for large files in the future.

The authentication mechanism is a little clunky right now and could definitely use streamlining. Generating an access token and manually putting it in a configuration file works if you're comfortable with that, but it isn't very user-friendly.

I have noticed an error that can occur when using an older version of Node.js. This may be due to partial support for promises. If you run into an error with a 'catch' or 'finally' and you can't update to the most recent version, let me know and I can look into a fix.