Introduction

In DSH plugin development or agent building, you often need to convert local images or files into Base64 encoding so they can be embedded directly in HTML or JSON. dsh-base64-file is designed for this need, providing a pure Node.js implementation of file ↔ Base64 conversion.

What It Is

This is a pure Node.js conversion tool, categorized under “Network Tools”, maintained by developer istone. It eliminates repetitive work related to file encoding conversion, supports converting local file paths to Base64 strings or data URLs, and also supports reverse reconstruction.

Core Features

  1. file_to_base64: file → base64/data URL
  2. base64_to_file: base64/data URL → file

Installation and Enablement

Use the official installation command:

dsh plugin add dsh-base64-file

After installation, add "dsh-base64-file" to the dsh.profile.bundles field in the profile’s package.json.

Typical Usage

After installation, directly call the registered tools in a session. For example, convert logo.png in the current directory to a data URL for embedding in HTML:

file_to_base64(file="logo.png")

Use Cases and Notes

This plugin is suitable for scenarios where files need to be embedded in text (such as HTML or JSON).
Note: Installing this plugin runs third-party code on your local machine. Please review the source code and license (MIT) yourself.

Follow-Up

The above content introduces how to install and use dsh-base64-file. For more details, refer to the GitHub repository or the DSH plugin directory.