Object storage and email

Whether uploaded files go to local storage or OBS, and whether email goes through SMTP or Resend, executed in four phases: before the change, during the change, verification, and rollback.

These are two independent operational switches:

  • Object storage: determines where uploaded files such as Skill packages and icons are stored
  • Email: determines how registration, password reset, and notification email is sent

If either one is misconfigured, the main business usually keeps running, but problems appear, such as "files upload but cannot be downloaded" or "verification codes never arrive".

1. Confirm before the change

Item Requirement How to confirm
Current storage method Local or OBS Upload a test file and check the download URL and where it lands on disk
OBS bucket and AK/SK Needed only when OBS is enabled The bucket is visible in the cloud console, and the AK/SK has read and write access to it
SMTP or Resend Needed only when email is configured The SMTP port is reachable, or the Resend domain is verified
Change window A service restart is required Object storage changes environment variables; email configuration file changes usually need no restart
Rollback plan The old configuration can be restored Back up grape.env and configs/email.json first

Do not overwrite the production grape.env without a backup. Either object storage or email may already have usable values in the old configuration.

2. Object storage (OBS)

When to use OBS

Scenario Recommendation
Single-machine trial, very few files Start with local storage; OBS is unnecessary
Multiple Workers that need to share uploaded files Use OBS so files are not stranded on one machine
Object lifecycle rules or cross-machine downloads are required Use OBS
The intranet cannot reach OBS Keep local storage and fix the network first

Local storage mode uploads files normally without OBS; that is the default behavior, not a fault.

Step 1: Prepare the bucket and credentials

  1. Create a bucket in the cloud console
  2. Create an AK/SK with read and write access to that bucket
  3. Record the endpoint, the bucket name, and the object prefix to use

Use one prefix per environment, for example:

grape/prod
grape/staging

Do not share one prefix across environments, or objects will be mixed together.

Step 2: Change the environment variables

Edit the environment file that actually takes effect (systemd's /etc/grape/grape.env, or Docker's .env):

OBS_ENABLED=true
OBS_ENDPOINT=https://obs.<region>.myhuaweicloud.com
OBS_BUCKET=<your-bucket-name>
OBS_ACCESS_KEY=<your-ak>
OBS_SECRET_KEY=<your-sk>
OBS_PREFIX=grape/prod
OBS_URL_EXPIRES=300
Variable Purpose Notes
OBS_ENABLED Master switch true/1/yes enables it; off by default
OBS_ENDPOINT OBS service address Use the actual region; do not copy the example
OBS_BUCKET Bucket name Must already exist
OBS_ACCESS_KEY / OBS_SECRET_KEY Access keys Keep them in environment variables only; never commit them to a repository
OBS_PREFIX Object prefix Must be isolated per environment
OBS_URL_EXPIRES Presigned link lifetime (seconds) Default 300; adjust to the download scenario

Step 3: Restart and verify

# systemd deployment: restart the actual unit name
sudo systemctl restart grape-server

# Docker deployment
cd deploy
docker compose --env-file ../.env up -d
docker compose --env-file ../.env ps

Verification order:

  1. Upload a test file in the console
  2. Download that file and confirm it opens
  3. Check the OBS console and confirm the object appears under OBS_PREFIX
  4. Confirm that the local storage directory no longer receives the file
  5. Check that the service log has no OBS authentication or network errors

"Upload succeeded" alone is not enough. Confirm that the object is actually in the bucket, that the download link works, and that no extra copy remains locally.

Step 4: Roll back

If OBS is unavailable:

  1. Set OBS_ENABLED to false
  2. Restart the service
  3. Upload a file again and confirm that it returns to local storage

Do not delete objects already uploaded to the bucket immediately. First confirm that no historical download links depend on them, then clean up according to the retention policy.

3. Email (SMTP / Resend)

Step 1: Choose a channel

Channel Suited to Configuration
SMTP Existing enterprise mailbox, QQ/163/Gmail smtp.host is non-empty
Resend No SMTP to maintain, and the sender domain can be verified resend.api_key is non-empty
None Temporary development use Degrades to log output in non-production environments

Actual selection order:

smtp.host non-empty → SMTP
otherwise resend.api_key non-empty → Resend
otherwise non-production → log only
otherwise production → send fails

mode and env in email.json are not channel criteria. The production decision comes from env in configs/security.json.

Step 2: Write the configuration

Copy the example:

cp configs/email.example.json configs/email.json
chmod 600 configs/email.json

SMTP example:

{
  "from_email": "noreply@example.com",
  "smtp": {
    "host": "smtp.example.com",
    "port": 465,
    "username": "<smtp-username>",
    "password": "<smtp-authorization-code>",
    "use_tls": true
  }
}

Resend example:

{
  "from_email": "noreply@example.com",
  "resend": {
    "api_key": "<resend-api-key>"
  }
}
Field Description
from_email The sender address recipients see; Resend requires a verified domain
smtp.host / smtp.port SMTP service address and port; 465 usually uses TLS, 587 uses STARTTLS
smtp.username / smtp.password Sender account and authorization code, not the login password
use_tls Set to true for ports 465/587 in most cases
resend.api_key Resend API key, not an SMTP password

Email configuration is usually read on every send, so changes need no restart; changing environment variables (such as SMTP_HOST) still requires one.

Step 3: Send a test email

  1. Open the sign-in page or the password reset page
  2. Enter your own email address and select send verification code
  3. Confirm that the email arrives and that the code passes validation
  4. Check the service log for SMTP/Resend errors

In production mode, fixed verification codes are ignored. Without a real email channel, users never receive a code, and the fixed code from development mode cannot be used as a workaround.

Step 4: Common failures

Symptom Likely cause Handling
535 Authentication failed The login password was used instead of the authorization code Generate a new SMTP authorization code
Connection timeout The port is blocked by a firewall, or the host is wrong Test telnet <host> <port> from the server
SSL handshake failure Port and use_tls do not match 465 uses implicit TLS; 587 uses STARTTLS
Email goes to spam The sender domain lacks SPF/DKIM Configure domain verification, SPF, and DKIM
Sending fails immediately in production No usable channel Configure smtp.host or resend.api_key
Changes do not take effect The wrong configuration file was edited Confirm the configs/ path the process actually reads

4. Completion criteria

  • [ ] Uploaded files can be downloaded and land in the expected location (local or OBS)
  • [ ] Objects appear under the matching prefix in the OBS bucket
  • [ ] Test email arrives and the verification code passes
  • [ ] The service log has no authentication, network, or TLS errors
  • [ ] The old configuration is backed up and the rollback path is known
  • [ ] Production does not depend on fixed verification codes or log fallback

Architecture and deployment topologies | Security baseline and engine scheduling | Upgrade, backup, and rollback