{"_id":"@aadvik-teklabs/zohodrive-uploader","_rev":"3-cc4588414157fbf559ea7148c27e6028","name":"@aadvik-teklabs/zohodrive-uploader","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@aadvik-teklabs/zohodrive-uploader","version":"1.0.0","keywords":["zoho","upload","api","express"],"author":{"name":"Aadvik Teklabs"},"license":"ISC","_id":"@aadvik-teklabs/zohodrive-uploader@1.0.0","maintainers":[{"name":"aadvik-teklabs","email":"info@aadviklabs.com"}],"dist":{"shasum":"8b804356ec08a7ff0105a55955880532842601d2","tarball":"https://registry.npmjs.org/@aadvik-teklabs/zohodrive-uploader/-/zohodrive-uploader-1.0.0.tgz","fileCount":7,"integrity":"sha512-qzxt8jXmXTo1lnUM44JscI7o6yHw98Ucwc1giNQk/1TAB+iTvwUbP9AgFQMYTOuNeqF6KZ3RzCgPOhYnMSluig==","signatures":[{"sig":"MEYCIQCywf8epd+CIhiNsmIqcedKvIlcZXyRt5J0Eggrx7aiyAIhAPZkCXKJR49xOhRKIo8WYxDkT4Hg4al3GLm6iW0SK71I","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":18270},"main":"index.js","gitHead":"cae046d76ab3bcb14fffe4c76ea220d5d298e3ec","scripts":{"dev":"nodemon demo/app.js","start":"node demo/app.js"},"_npmUser":{"name":"aadvik-teklabs","email":"info@aadviklabs.com"},"_npmVersion":"11.12.1","description":"API to upload images and PDFs to Zoho WorkDrive","directories":{},"_nodeVersion":"24.15.0","dependencies":{"cors":"^2.8.5","axios":"^1.6.0","dotenv":"^16.3.1","multer":"^1.4.5-lts.1","yamljs":"^0.3.0","express":"^4.18.2","form-data":"^4.0.0","swagger-ui-express":"^5.0.0"},"_hasShrinkwrap":false,"devDependencies":{"nodemon":"^3.0.1"},"_npmOperationalInternal":{"tmp":"tmp/zohodrive-uploader_1.0.0_1783078752247_0.10587235569451403","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@aadvik-teklabs/zohodrive-uploader","version":"1.0.1","keywords":["zoho","upload","api","express"],"author":{"name":"Aadvik Teklabs"},"license":"ISC","_id":"@aadvik-teklabs/zohodrive-uploader@1.0.1","maintainers":[{"name":"aadvik-teklabs","email":"info@aadviklabs.com"}],"dist":{"shasum":"92939ac2855366213f5be14fb931e99ff5af977b","tarball":"https://registry.npmjs.org/@aadvik-teklabs/zohodrive-uploader/-/zohodrive-uploader-1.0.1.tgz","fileCount":7,"integrity":"sha512-kK0OTrDScmAum6zYoCRLhJK3uvB+PC7shSGi0bm86cQQwjx7j641WClc6jLJIeKjoanaWsOBd+mVgksLL8GtLA==","signatures":[{"sig":"MEQCIFDY3gniIWLTiqIA+DkvEAZhpX9W8EMJtg8cMcMNBJOIAiAO1f0ot0V2dX0zPQFWK7JruSo99NyWuJKABm+LSso13Q==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":18272},"main":"index.js","gitHead":"cae046d76ab3bcb14fffe4c76ea220d5d298e3ec","scripts":{"dev":"nodemon demo/app.js","start":"node demo/app.js"},"_npmUser":{"name":"aadvik-teklabs","email":"info@aadviklabs.com"},"_npmVersion":"11.12.1","description":"API to upload images and PDFs to Zoho WorkDrive","directories":{},"_nodeVersion":"24.15.0","dependencies":{"cors":"^2.8.5","axios":"^1.6.0","dotenv":"^16.3.1","multer":"^1.4.5-lts.1","yamljs":"^0.3.0","express":"^4.18.2","form-data":"^4.0.0","swagger-ui-express":"^5.0.0"},"_hasShrinkwrap":false,"devDependencies":{"nodemon":"^3.0.1"},"_npmOperationalInternal":{"tmp":"tmp/zohodrive-uploader_1.0.1_1783080122694_0.9976107690002796","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@aadvik-teklabs/zohodrive-uploader","version":"1.0.2","description":"API to upload images and PDFs to Zoho WorkDrive","main":"index.js","scripts":{"start":"node demo/app.js","dev":"nodemon demo/app.js"},"keywords":["zoho","upload","api","express"],"author":{"name":"Aadvik Teklabs"},"license":"ISC","dependencies":{"axios":"^1.6.0","cors":"^2.8.5","dotenv":"^16.3.1","express":"^4.18.2","form-data":"^4.0.0","multer":"^1.4.5-lts.1","swagger-ui-express":"^5.0.0","yamljs":"^0.3.0"},"devDependencies":{"nodemon":"^3.0.1"},"gitHead":"0f8c36dc6ed977278ffc203384c66dafb06016e3","_id":"@aadvik-teklabs/zohodrive-uploader@1.0.2","_nodeVersion":"24.15.0","_npmVersion":"11.12.1","dist":{"integrity":"sha512-fJWITWw+ZmPZqsDkYp6qPvxDggUiDLI0qTG6p6Lbm8aPxrjrfEZ0GqBvWAYwbRlgMY3G344TdMSuQU6ZEQu/fA==","shasum":"09094b76d6eec7b466e062473989bb442ec33f8b","tarball":"https://registry.npmjs.org/@aadvik-teklabs/zohodrive-uploader/-/zohodrive-uploader-1.0.2.tgz","fileCount":7,"unpackedSize":18323,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQC3MjFuZPyHzDJVAICm+zdGW2vsb0vpnEcICqNhGlkb4QIgSU68eBOuemQdWX27chGfH9edgKEPCxJfPSN07maX69E="}]},"_npmUser":{"name":"aadvik-teklabs","email":"info@aadviklabs.com"},"directories":{},"maintainers":[{"name":"aadvik-teklabs","email":"info@aadviklabs.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/zohodrive-uploader_1.0.2_1783081326381_0.44083011470405853"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-03T11:39:12.083Z","modified":"2026-07-03T12:22:06.650Z","1.0.0":"2026-07-03T11:39:12.398Z","1.0.1":"2026-07-03T12:02:02.841Z","1.0.2":"2026-07-03T12:22:06.520Z"},"author":{"name":"Aadvik Teklabs"},"license":"ISC","keywords":["zoho","upload","api","express"],"description":"API to upload images and PDFs to Zoho WorkDrive","maintainers":[{"name":"aadvik-teklabs","email":"info@aadviklabs.com"}],"readme":"﻿# Zoho WorkDrive Asset Uploader\r\n\r\nA 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.\r\n\r\n---\r\n\r\n## ðŸš€ Features\r\n\r\n*   **Universal Uploader**: Supports JPG, PNG, WEBP, SVG, and PDF files.\r\n*   **Automatic Auth**: Handles Zoho OAuth2 Token generation and refreshing automatically.\r\n*   **Secure**: Uses Environment variables for sensitive credentials.\r\n*   **Smart Validation**: Validates file types before attempting upload.\r\n\r\n---\r\n\r\n## ðŸ“¦ Installation\r\n\r\nInstall the package into your project via npm:\r\n\r\n```bash\r\nnpm install @aadvik-teklabs/zohodrive-uploader\r\n```\r\n\r\n---\r\n\r\n## ðŸš€ Usage\r\nSince 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.\r\n\r\nconst ZohoWorkDriveUploader = require('zohodrive-asset-uploader');\r\n\r\n// Initialize the uploader with your credentials\r\nconst uploader = new ZohoWorkDriveUploader({\r\n    clientId: 'YOUR_CLIENT_ID',\r\n    clientSecret: 'YOUR_CLIENT_SECRET',\r\n    refreshToken: 'YOUR_REFRESH_TOKEN',\r\n    folderId: 'YOUR_FOLDER_ID',\r\n    accountsUrl: '[https://accounts.zoho.in](https://accounts.zoho.in)' // Optional: defaults to .com\r\n});\r\n\r\n/**\r\n * Example function to handle a file upload\r\n * @param {string} fileName - Name of the file (e.g., 'invoice.pdf')\r\n * @param {Buffer} fileBuffer - The binary buffer of the file\r\n * @param {string} mimeType - The file type (e.g., 'application/pdf')\r\n */\r\nasync function uploadToZoho(fileName, fileBuffer, mimeType) {\r\n    try {\r\n        const result = await uploader.upload(fileName, fileBuffer, mimeType);\r\n        console.log('Upload Success! Resource ID:', result.attachmentId);\r\n    } catch (error) {\r\n        console.error('Upload Failed:', error.message);\r\n    }\r\n}\r\n\r\n## ðŸ› ï¸ Setup & Configuration\r\n\r\n### 1. Prerequisites\r\n*   Node.js installed.\r\n*   A Zoho account (India DC `zoho.in` or Global `zoho.com`).\r\n\r\n### 2. Zoho API Credentials\r\n1.  Go to the [Zoho API Console](https://api-console.zoho.com/).\r\n2.  Create a **Self Client**.\r\n3.  Note down your **Client ID** and **Client Secret**.\r\n\r\n\r\n### 5. Generate Refresh Token (One-Time Setup)\r\nYou only need to do this **once**. The token generated here is permanent.\r\n1.  Run the helper script:\r\n    ```bash\r\n    node scripts/generateToken.js\r\n    ```\r\n---\r\n\r\n## â–¶ï¸ Running the Demo\r\nIf you want to test the package logic using the built in Express server:\r\n1. Ensure your .env file is configured in the root directory with your credentials\r\n\r\nStart the server:\r\n```bash\r\nnode demo/app.js\r\n```\r\n\r\nUser Interface (Swagger UI):\r\n> **http://localhost:3000/api-docs**\r\n\r\n---\r\n\r\n\r\n## ðŸ—ï¸ Project Structure\r\n\r\n*   **`index.js`**: Main entry point for the npm package.\r\n*   **`src/routes`**: Defines API interaction points (e.g., `/api/upload`).\r\n*   **`src/controllers`**: logic layer. Validates requests and calls services.\r\n*   **`src/services/zohoService.js`**: The core engine.\r\n    *   Manages OAuth tokens (checks if valid, or refreshes them).\r\n    *   Uploads the actual file to Zoho WorkDrive.\r\n*   **`demo/:`**: Contains the demonstration Express server and swagger.yaml.\r\n*   **`scripts/generateToken.js`**: Utility tool for first-time setup.\r\n\r\n---\r\n\r\n## ðŸ”„ How Authentication Works\r\n1.  The Library checks for a valid **Access Token** in memory.\r\n2.  If the token is expired or missing, it uses the Refresh Token to request a new one from    Zoho automatically\r\n3.  The new token is cached, ensuring seamless and uninterrupted file uploads.\r\n6.  **Result**: Seamless, uninterrupted uploads forever.\r\n\r\n","readmeFilename":"README.md"}