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

@aadvik-teklabs/zohodrive-uploader

v1.0.2

Published

API to upload images and PDFs to Zoho WorkDrive

Readme

Zoho WorkDrive Asset Uploader

A Profesional Node.js library designed to upload images and PDF files securely to Zoho WorkDrive. This package handles OAuth2 authentication automatically, using a long-lived Refresh Token to maintain persistent access without manual intervention.


🚀 Features

  • Universal Uploader: Supports JPG, PNG, WEBP, SVG, and PDF files.
  • Automatic Auth: Handles Zoho OAuth2 Token generation and refreshing automatically.
  • Secure: Uses Environment variables for sensitive credentials.
  • Smart Validation: Validates file types before attempting upload.

📦 Installation

Install the package into your project via npm:

npm install @aadvik-teklabs/zohodrive-uploader

🚀 Usage

Since this is a modular library, you import the ZohoWorkDriveUploader class and initialize it with your credentials. This avoids the use of global environment variables within the core logic.

const ZohoWorkDriveUploader = require('zohodrive-asset-uploader');

// Initialize the uploader with your credentials const uploader = new ZohoWorkDriveUploader({ clientId: 'YOUR_CLIENT_ID', clientSecret: 'YOUR_CLIENT_SECRET', refreshToken: 'YOUR_REFRESH_TOKEN', folderId: 'YOUR_FOLDER_ID', accountsUrl: 'https://accounts.zoho.in' // Optional: defaults to .com });

/**

  • Example function to handle a file upload
  • @param {string} fileName - Name of the file (e.g., 'invoice.pdf')
  • @param {Buffer} fileBuffer - The binary buffer of the file
  • @param {string} mimeType - The file type (e.g., 'application/pdf') */ async function uploadToZoho(fileName, fileBuffer, mimeType) { try { const result = await uploader.upload(fileName, fileBuffer, mimeType); console.log('Upload Success! Resource ID:', result.attachmentId); } catch (error) { console.error('Upload Failed:', error.message); } }

🛠️ Setup & Configuration

1. Prerequisites

  • Node.js installed.
  • A Zoho account (India DC zoho.in or Global zoho.com).

2. Zoho API Credentials

  1. Go to the Zoho API Console.
  2. Create a Self Client.
  3. Note down your Client ID and Client Secret.

5. Generate Refresh Token (One-Time Setup)

You only need to do this once. The token generated here is permanent.

  1. Run the helper script:
    node scripts/generateToken.js

▶️ Running the Demo

If you want to test the package logic using the built in Express server:

  1. Ensure your .env file is configured in the root directory with your credentials

Start the server:

node demo/app.js

User Interface (Swagger UI):

http://localhost:3000/api-docs


🏗️ Project Structure

  • index.js: Main entry point for the npm package.
  • src/routes: Defines API interaction points (e.g., /api/upload).
  • src/controllers: logic layer. Validates requests and calls services.
  • src/services/zohoService.js: The core engine.
    • Manages OAuth tokens (checks if valid, or refreshes them).
    • Uploads the actual file to Zoho WorkDrive.
  • demo/:: Contains the demonstration Express server and swagger.yaml.
  • scripts/generateToken.js: Utility tool for first-time setup.

🔄 How Authentication Works

  1. The Library checks for a valid Access Token in memory.
  2. If the token is expired or missing, it uses the Refresh Token to request a new one from Zoho automatically
  3. The new token is cached, ensuring seamless and uninterrupted file uploads.
  4. Result: Seamless, uninterrupted uploads forever.