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 🙏

© 2026 – Pkg Stats / Ryan Hefner

cloud-storage-picker

v0.0.1

Published

Pick files from a cloud storage provider such as Dropbox, Google Drive and more.

Readme

Cloud Storage Picker

A lightweight, TypeScript-first library for integrating file pickers from popular cloud storage providers like Dropbox and Google Drive into your web applications.

Features

  • 🎯 Type-safe - Built with TypeScript for full type safety and IntelliSense support
  • 🔌 Pluggable - Easy-to-use provider architecture for different cloud storage services
  • 🪶 Lightweight - Minimal bundle size with on-demand script loading
  • 🎨 Framework agnostic - Works with React, Vue, Svelte, or vanilla JavaScript
  • 📦 Tree-shakeable - Import only the providers you need

Supported Providers

  • ✅ Dropbox
  • ✅ Google Drive
  • 🔜 OneDrive (coming soon)

Installation

npm install cloud-storage-picker
pnpm add cloud-storage-picker
yarn add cloud-storage-picker

Quick Start

Dropbox

import { createPicker } from "cloud-storage-picker";
import { dropboxProvider } from "cloud-storage-picker/dropbox";

const picker = createPicker({
  provider: dropboxProvider({
    appKey: "your-dropbox-app-key",
  }),
});

// Open the picker
const files = await picker.open({
  multiSelect: true,
  linkType: "preview",
});

console.log(files);
// [{ id: '...', name: 'document.pdf', link: 'https://...', rawData: {...} }]

Google Drive

import { createPicker } from "cloud-storage-picker";
import { googleDriveProvider } from "cloud-storage-picker/google-drive";

const picker = createPicker({
  provider: googleDriveProvider({
    clientId: "your-google-client-id",
    apiKey: "your-google-api-key",
  }),
});

// Open the picker
const files = await picker.open({
  maxItems: 5,
});

console.log(files);
// [{ id: '...', name: 'presentation.pptx', link: 'https://...', rawData: {...} }]

API Reference

createPicker(params)

Creates a file picker instance for a given storage provider.

Parameters:

  • params.provider - A storage provider instance (e.g., dropboxProvider() or googleDriveProvider())

Returns:

  • An object with an open(options?) method that returns a Promise<FileData[]>

FileData<T>

The normalized file data structure returned by all providers:

interface FileData<RawFileData> {
  id: string; // Unique identifier for the file
  name: string; // Name of the file
  link: string; // URL to access the file
  rawData: RawFileData; // Provider-specific raw file data
}

Provider-Specific Documentation

Dropbox Provider

Configuration

dropboxProvider(config: DropboxConfig, options?: DropboxOptions)

DropboxConfig:

DropboxOptions:

  • linkType: "preview" | "direct" - Type of link to return (default: "preview")
  • multiSelect: boolean - Enable multiple file selection (default: false)
  • extensions: string[] - Filter by file extensions or types (e.g., [".pdf", "images"])
  • folderSelect: boolean - Allow folder selection (default: false)
  • sizeLimit: number - Maximum file size in bytes

DropboxFileData:

interface DropboxFileData {
  id: string;
  name: string;
  bytes: number;
  isDir: boolean;
  link: string;
  linkType: "preview" | "direct";
  icon: string;
  thumbnailLink?: string;
}

Example

const picker = createPicker({
  provider: dropboxProvider(
    { appKey: "your-app-key" },
    {
      multiSelect: true,
      extensions: [".pdf", ".docx", "images"],
      sizeLimit: 10 * 1024 * 1024, // 10MB
    },
  ),
});

const files = await picker.open();

Google Drive Provider

Configuration

googleDriveProvider(config: GoogleDriveConfig, options?: GoogleDriveOptions)

GoogleDriveConfig:

  • clientId (required): Your Google OAuth 2.0 Client ID
  • apiKey (required): Your Google API Key

Get credentials from the Google Cloud Console.

GoogleDriveOptions:

  • maxItems: number - Maximum number of items a user can select

GoogleDriveFileData:

interface GoogleDriveFileData {
  id: string;
  name: string;
  mimeType: string;
  url: string;
}

Example

const picker = createPicker({
  provider: googleDriveProvider(
    {
      clientId: "your-client-id.apps.googleusercontent.com",
      apiKey: "your-api-key",
    },
    { maxItems: 3 },
  ),
});

const files = await picker.open();

Advanced Usage

Default Options

You can set default options when creating a provider and override them per call:

const picker = createPicker({
  provider: dropboxProvider(
    { appKey: "your-app-key" },
    { multiSelect: false }, // Default
  ),
});

// Override defaults for specific calls
const singleFile = await picker.open(); // Uses multiSelect: false
const multipleFiles = await picker.open({ multiSelect: true }); // Override

Error Handling

try {
  const files = await picker.open();
  console.log("Selected files:", files);
} catch (error) {
  if (error.message.includes("cancelled")) {
    console.log("User cancelled the picker");
  } else {
    console.error("Picker error:", error);
  }
}

Accessing Raw Provider Data

Each FileData object includes a rawData property with the complete, unmodified response from the provider:

const files = await picker.open();

files.forEach((file) => {
  console.log("Normalized:", file.id, file.name);
  console.log("Raw Dropbox data:", file.rawData);
  // Access provider-specific fields like bytes, icon, thumbnailLink, etc.
});

Setup Requirements

Dropbox

  1. Create an app at the Dropbox App Console
  2. Enable "Chooser" permissions
  3. Add your domain to the allowed domains list
  4. Copy your App Key

Google Drive

  1. Go to the Google Cloud Console
  2. Create a new project or select an existing one
  3. Enable the Google Picker API and Google Drive API
  4. Create OAuth 2.0 credentials:
    • Add authorized JavaScript origins (e.g., http://localhost:3000)
  5. Create an API Key
  6. Copy your Client ID and API Key

License

MIT © Melvin Otieno

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Links


Made with ❤️ by Melvin Otieno