DocumentionUmo Office ConvertEnvironment Variables

Environment Variable Configuration

The .env file is mainly used to configure the application runtime environment and parameters. It separates configuration from code and makes deployment management for different environments (development/test/production) easier. You can adjust application behavior by editing the configuration file without changing source code, improving deployment flexibility and security.

Copy the .env.example file in the root directory, rename it to .env, place it in the project root directory, and modify the values as needed.

Configuration Items

For a complete .env example, see .env.example. Below is a detailed explanation of each configuration item.

Node Environment

# node environment
NODE_ENV = production

Service Configuration

PORT = 1236
SERVER_NAME = Umo Office Convert

Logging Configuration

LOG_DIR = ./logs

File Upload Configuration

# Maximum allowed upload size in MB
MAX_FILE_SIZE = 50

Document Storage Path Configuration

UPLOAD_DIR = ./uploads/[year]/[month]
CONVERTED_DIR = ./converted/[year]/[month]

Document Cover and Summary

# Whether to generate a document cover
ENABLE_COVER = true
# Document cover storage path
COVER_DIR = ./temp/cover/[year]/[month]
# Maximum summary length; truncate and append ellipsis if exceeded
SUMMARY_LENGTH = 200

File Hash Algorithm Configuration

FILE_HASH_ALGORITHM = sha256

MySQL Database Configuration

DB_HOST = localhost
DB_PORT = 3306
DB_USER = root
DB_PASSWORD =
DB_NAME = umo_office_convert
DB_TABLE_CONVERT_TASKS = convert_tasks

Webhook Configuration

CONVERTED_WEBHOOK_URL =

Important Notes

Path Variable Notes

  • [year], [month], and [day] are dynamic path variables. The system will automatically replace them based on the current date. For example, ./uploads/[year]/[month] may generate a path like ./uploads/2024/01.
  • If an upload directory is not specified, uploaded files will not be saved.

Security Notes

  1. Database password: set DB_PASSWORD according to your environment.
  2. File size limit: adjust MAX_FILE_SIZE according to your needs to avoid exhausting server resources.

Hash Algorithm Selection

  • The file hash algorithm is used to generate a unique identifier for a file. The supported algorithm list varies depending on your Node.js version, operating system, and OpenSSL version. Common algorithms include md5, sha1, sha256, and sha512.
  • If you change the hash algorithm, ensure the length of the hash field in the database table is sufficient to store the hash value.

Webhook Functionality

  • CONVERTED_WEBHOOK_URL is used to receive file processing status notifications. The configured URL should accept POST requests without authorization.
  • When a file is uploaded or a file conversion is completed, the system will send a POST request to the configured Webhook URL, containing information related to the conversion task.
  • Leaving it empty or not configuring it means the Webhook feature is not enabled.