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

node-red-google-drive-storage

v1.0.1

Published

[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)

Readme

Node-RED Google Drive Integration

License

Модуль Node-RED для загрузки, удаления и управления файлами на Google Диске. Поддерживает два метода аутентификации: Service Account и OAuth 2.0.

Содержание

  1. Описание
  2. Установка
  3. Настройка
  4. Использование
  5. Примеры
  6. Лицензия

Описание

Этот модуль предоставляет три узла для работы с Google Диском:

  1. Конфигурационный узел: Настройка аутентификации (Service Account или OAuth 2.0).
  2. Добавление файлов: Загрузка файлов на Google Диск.
  3. Удаление файлов: Удаление файлов с Google Диска.

Файлы автоматически становятся доступными для просмотра после загрузки.


Установка

  1. Убедитесь, что у вас установлен Node-RED:

    npm install -g node-red
  2. Установите модуль:

    npm install node-red-google-drive-storage
  3. Перезапустите Node-RED:

    node-red

Настройка

1. Создание учетных данных Google API

Для работы с Google Диском необходимо создать учетные данные в Google Cloud Console:

  • Service Account:

    1. Создайте новый проект в Google Cloud Console.
    2. Активируйте API Google Drive.
    3. Создайте Service Account и скачайте JSON-файл с учетными данными.
  • OAuth 2.0:

    1. Создайте OAuth 2.0 Client ID.
    2. Получите Refresh Token через процесс авторизации.

2. Настройка узлов

Конфигурационный узел

  1. Добавьте конфигурационный узел (google-drive-config) в панель конфигурации.
  2. Выберите тип аутентификации:
    • Для Service Account: Вставьте содержимое JSON-файла в поле "Учетные данные Service Account".
    • Для OAuth 2.0: Введите Client ID, Client Secret, Redirect URI и Refresh Token.

Использование

Конфигурационный узел

  • Название: google-drive-config
  • Описание: Настройка аутентификации для взаимодействия с Google API.
  • Параметры:
    • Тип аутентификации: Service Account или OAuth 2.0.
    • Учетные данные: JSON для Service Account или параметры OAuth 2.0.

Добавление файлов

  • Название: google-drive-upload
  • Описание: Загружает файлы на Google Диск.
  • Входные данные:
    • msg.payload: Файл в формате Buffer.
    • msg.fileName (опционально): Имя файла.
    • msg.mimeType (опционально): MIME-тип файла.
  • Выходные данные:
    • msg.fileId: ID загруженного файла.
    • msg.webViewLink: Ссылка для просмотра файла.

Удаление файлов

  • Название: google-drive-delete
  • Описание: Удаляет файлы с Google Диска.
  • Входные данные:
    • msg.fileId: ID файла для удаления.
  • Выходные данные:
    • msg.deletedFileId: ID удаленного файла.

Примеры

1. Загрузка файла через HTTP POST

Создайте Flow для загрузки файла через HTML-форму:

[
    {
        "id": "a1",
        "type": "http in",
        "z": "flow",
        "name": "GET /",
        "url": "/",
        "method": "get",
        "upload": false,
        "swaggerDoc": "",
        "x": 150,
        "y": 100,
        "wires": [["a2"]]
    },
    {
        "id": "a2",
        "type": "template",
        "z": "flow",
        "name": "HTML Form",
        "field": "payload",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "<form id=\"uploadForm\" enctype=\"multipart/form-data\" method=\"POST\" action=\"/upload\">\n    <label for=\"file\">Выберите файл:</label>\n    <input type=\"file\" id=\"file\" name=\"file\" accept=\"image/*\" required>\n    <br><br>\n    <button type=\"submit\">Загрузить</button>\n</form>",
        "output": "str",
        "x": 350,
        "y": 100,
        "wires": [["a3"]]
    },
    {
        "id": "a3",
        "type": "http response",
        "z": "flow",
        "name": "",
        "statusCode": "",
        "headers": {},
        "x": 550,
        "y": 100,
        "wires": []
    },
    {
        "id": "b1",
        "type": "http in",
        "z": "flow",
        "name": "POST /upload",
        "url": "/upload",
        "method": "post",
        "upload": true,
        "swaggerDoc": "",
        "x": 150,
        "y": 200,
        "wires": [["b2"]]
    },
    {
        "id": "b2",
        "type": "function",
        "z": "flow",
        "name": "Process File",
        "func": "const file = msg.req.files.file;\nmsg.payload = Buffer.from(file.data);\nmsg.fileName = file.name;\nmsg.mimeType = file.type;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 350,
        "y": 200,
        "wires": [["b3"]]
    },
    {
        "id": "b3",
        "type": "google-drive-upload",
        "z": "flow",
        "name": "Upload to Google Drive",
        "googleDriveConfig": "config-node-id", // Укажите ID конфигурационного узла
        "fileName": "",
        "x": 550,
        "y": 200,
        "wires": [["b4"]]
    },
    {
        "id": "b4",
        "type": "http response",
        "z": "flow",
        "name": "",
        "statusCode": "200",
        "headers": {},
        "x": 750,
        "y": 200,
        "wires": []
    }
]

2. Удаление файла

Создайте Flow для удаления файла по его ID:

[
    {
        "id": "c1",
        "type": "inject",
        "z": "flow",
        "name": "Delete File",
        "props": [
            { "p": "fileId", "v": "1abc123...", "vt": "str" }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "x": 150,
        "y": 300,
        "wires": [["c2"]]
    },
    {
        "id": "c2",
        "type": "google-drive-delete",
        "z": "flow",
        "name": "Delete from Google Drive",
        "googleDriveConfig": "config-node-id", // Укажите ID конфигурационного узла
        "fileId": "",
        "x": 350,
        "y": 300,
        "wires": [["c3"]]
    },
    {
        "id": "c3",
        "type": "debug",
        "z": "flow",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 550,
        "y": 300,
        "wires": []
    }
]

Лицензия

Этот проект распространяется под лицензией MIT. Подробности см. в файле LICENSE.


Поддержка

Если у вас возникли вопросы или проблемы, создайте issue в репозитории или свяжитесь с автором.


Автор: Borovlioff GitHub: https://github.com/borovlioff/node-red-google-drive-storage