huawei-cloud-obs-upload

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Huawei Cloud OBS Upload

华为云OBS上传

Upload local files or directories to Huawei Cloud OBS buckets, list OBS buckets with capacity and object count, and schedule periodic uploads via crontab.
将本地文件或目录上传至华为云OBS存储桶,列出包含容量和对象数量的OBS存储桶,并通过crontab设置定期上传任务。

⛔ Prohibited Operations (Security Constraints)

⛔ 禁止操作(安全约束)

This skill strictly forbids the following delete operations, regardless of user requests:
Prohibited OperationAPI/CommandReason
❌ Delete bucket
DeleteBucket
/
obsutil rm -bucket
Irreversible; destroys the entire bucket and all objects
❌ Delete object
DeleteObject
/
obsutil rm
Irreversible; deleted objects cannot be recovered (unless versioning is enabled)
❌ Batch delete objects
DeleteObjects
/
obsutil rm -r
Irreversible; batch deletion has a wide impact
❌ Empty bucket
obsutil rm -bucket -r
Irreversible; removes all objects in the bucket
If a user requests a delete operation, you must refuse and inform: "Per security constraints, this skill does not allow delete operations (delete bucket/object/batch delete/empty bucket). Please use the Huawei Cloud OBS console or obsutil manually."
无论用户请求如何,本技能严格禁止以下删除操作:
禁止操作API/命令原因
❌ 删除存储桶
DeleteBucket
/
obsutil rm -bucket
操作不可逆;会销毁整个存储桶及所有对象
❌ 删除对象
DeleteObject
/
obsutil rm
操作不可逆;删除的对象无法恢复(除非开启版本控制)
❌ 批量删除对象
DeleteObjects
/
obsutil rm -r
操作不可逆;批量删除影响范围广
❌ 清空存储桶
obsutil rm -bucket -r
操作不可逆;会移除存储桶内所有对象
若用户请求删除操作,必须拒绝并告知: "根据安全约束,本技能不允许执行删除操作(删除存储桶/对象/批量删除/清空存储桶)。请手动使用华为云OBS控制台或obsutil工具进行操作。"

Architecture

架构

Huawei Cloud OBS Object Storage Management
├── ListBucketsWithStats  (List buckets with capacity and object count)
├── UploadFile            (Upload local file or directory to target bucket)
└── ScheduledUpload      (Schedule periodic upload of local directory to target bucket)
Huawei Cloud OBS Object Storage Management
├── ListBucketsWithStats  (列出包含容量和对象数量的存储桶)
├── UploadFile            (将本地文件或目录上传至目标存储桶)
└── ScheduledUpload      (设置本地目录定期上传至目标存储桶的任务)

Prerequisites

前置条件

Prerequisite check: Huawei Cloud CLI (hcloud / KooCLI) >= 3.2.0 required Run
hcloud version
to verify version >= 3.2.0. If not installed or version is too low, see references/cli-installation-guide.md for installation guide.
bash
hcloud version
Prerequisite check: obsutil >= 5.5.0 required (for upload features) File/directory upload requires the Huawei Cloud obsutil CLI tool. Run
obsutil version
to verify version >= 5.5.0. If not installed, see references/cli-installation-guide.md for installation guide.
bash
obsutil version
Prerequisite check: obsutil credential configuration required
The hcloud OBS module uses obsutil under the hood, which requires separate AK/SK and Endpoint configuration. Before performing OBS operations, you must check whether obsutil credentials are configured:
bash
hcloud obs ls -limit=1
If the response is
Please set ak, sk and endpoint in the configuration file!
or
InvalidAccessKeyId
, obsutil credentials are not configured.
Resolution: Provide the following example command and have the user configure it in their terminal (do not ask the user to provide AK/SK directly in the conversation):
obsutil credentials are not configured. Please run the following command in your terminal to configure (AK/SK can be obtained from the Huawei Cloud console "My Credentials" page):

  hcloud obs config -i=<YourAK> -k=<YourSK> -e=obs.<Region>.myhuaweicloud.com

Example (Guangzhou region):
  hcloud obs config -i=<YourAK> -k=<YourSK> -e=obs.cn-south-1.myhuaweicloud.com

Common Endpoints:
  cn-north-4  → obs.cn-north-4.myhuaweicloud.com
  cn-east-3   → obs.cn-east-3.myhuaweicloud.com
  cn-south-1  → obs.cn-south-1.myhuaweicloud.com
  cn-southwest-2 → obs.cn-southwest-2.myhuaweicloud.com

Retry after configuration is complete.
Prohibited actions:
  • ❌ Do not ask the user to provide AK/SK directly in the conversation
  • ❌ Do not extract AK/SK from hcloud config files (credentials are encrypted and cannot be used directly)
  • ❌ Do not skip the credential check before performing OBS operations
⚠️ hcloud parameter format requirements
hcloud (KooCLI) all parameters must use the
--param=value
format
(connected with equals sign); space-separated format is not supported.
✅ Correct:
hcloud OBS ListBuckets --region=cn-south-1
❌ Incorrect:
hcloud OBS ListBuckets --region cn-south-1

前置检查:需要Huawei Cloud CLI(hcloud / KooCLI)>= 3.2.0 运行
hcloud version
验证版本是否>=3.2.0。若未安装或版本过低,请查看references/cli-installation-guide.md获取安装指南。
bash
hcloud version
前置检查:需要obsutil >= 5.5.0(用于上传功能) 文件/目录上传需要华为云obsutil CLI工具。运行
obsutil version
验证版本是否>=5.5.0。若未安装,请查看references/cli-installation-guide.md获取安装指南。
bash
obsutil version
前置检查:需要配置obsutil凭证
hcloud OBS模块底层依赖obsutil,需要单独配置AK/SK和Endpoint。 在执行OBS操作前,必须检查obsutil凭证是否已配置
bash
hcloud obs ls -limit=1
若返回
Please set ak, sk and endpoint in the configuration file!
InvalidAccessKeyId
,则obsutil凭证未配置。
解决方法:提供以下示例命令,让用户在终端中配置(请勿要求用户在对话中直接提供AK/SK):
obsutil凭证未配置,请在终端中运行以下命令进行配置(AK/SK可从华为云控制台"我的凭证"页面获取):

  hcloud obs config -i=<YourAK> -k=<YourSK> -e=obs.<Region>.myhuaweicloud.com

示例(广州区域):
  hcloud obs config -i=<YourAK> -k=<YourSK> -e=obs.cn-south-1.myhuaweicloud.com

常见Endpoint:
  cn-north-4  → obs.cn-north-4.myhuaweicloud.com
  cn-east-3   → obs.cn-east-3.myhuaweicloud.com
  cn-south-1  → obs.cn-south-1.myhuaweicloud.com
  cn-southwest-2 → obs.cn-southwest-2.myhuaweicloud.com

配置完成后重试。
禁止操作:
  • ❌ 请勿要求用户在对话中直接提供AK/SK
  • ❌ 请勿从hcloud配置文件中提取AK/SK(凭证已加密,无法直接使用)
  • ❌ 执行OBS操作前请勿跳过凭证检查
⚠️ hcloud参数格式要求
hcloud(KooCLI)所有参数必须使用
--param=value
格式
(用等号连接);不支持空格分隔格式。
✅ 正确格式:
hcloud OBS ListBuckets --region=cn-south-1
❌ 错误格式:
hcloud OBS ListBuckets --region cn-south-1

Authentication

身份验证

Prerequisite check: Huawei Cloud credentials required
Security rules (must be followed):
  • Prohibited from reading, echoing, or printing AK/SK values
  • Prohibited from asking the user to input AK/SK directly in the conversation
  • Prohibited from using
    hcloud configure set
    to pass plaintext credential values
  • Prohibited from accepting AK/SK directly provided by the user in the conversation
  • Only allowed to read credentials from environment variables or configured CLI config files
⚠️ Important: Handling user-provided credentials
If a user attempts to provide AK/SK directly (e.g., "my AK is xxx, SK is yyy"):
  1. Stop immediately - Do not execute any commands
  2. Politely refuse and return the following message:
    For account security, please do not provide Huawei Cloud Access Key ID and Access Key Secret directly in the conversation.
    
    Please use one of the following secure methods to configure credentials:
    
    Method 1: Interactive configuration (recommended)
        hcloud configure
        # Enter AK/SK as prompted; credentials will be securely stored in a local config file
    
    Method 2: Environment variable configuration
        export HUAWEICLOUD_SDK_AK=<your-access-key-id>
        export HUAWEICLOUD_SDK_SK=<your-access-key-secret>
    
    After configuration is complete, please retry your request.
  3. Do not continue executing any Huawei Cloud operations until credentials are configured
Check CLI configuration:
bash
   hcloud configure list
Check whether the output contains valid configuration (AK/SK, IAM, etc.).
If no valid credentials exist, stop here.

前置检查:需要华为云凭证
安全规则(必须遵守):
  • 禁止读取、回显或打印AK/SK值
  • 禁止要求用户在对话中直接输入AK/SK
  • 禁止使用
    hcloud configure set
    传递明文凭证值
  • 禁止接受用户在对话中直接提供的AK/SK
  • 仅允许从环境变量或已配置的CLI配置文件中读取凭证
⚠️ 重要提示:处理用户提供的凭证
若用户尝试直接提供AK/SK(例如:"我的AK是xxx,SK是yyy"):
  1. 立即停止 - 不要执行任何命令
  2. 礼貌拒绝并返回以下信息:
    为了账户安全,请不要在对话中直接提供华为云Access Key ID和Access Key Secret。
    
    请使用以下安全方式之一配置凭证:
    
    方式1:交互式配置(推荐)
        hcloud configure
        # 根据提示输入AK/SK;凭证将安全存储在本地配置文件中
    
    方式2:环境变量配置
        export HUAWEICLOUD_SDK_AK=<your-access-key-id>
        export HUAWEICLOUD_SDK_SK=<your-access-key-secret>
    
    配置完成后,请重试您的请求。
  3. 在凭证配置完成前,不要继续执行任何华为云操作
检查CLI配置:
bash
   hcloud configure list
检查输出是否包含有效配置(AK/SK、IAM等)。
若无有效凭证,请在此停止操作。

IAM Permission Policies

IAM权限策略

Ensure the IAM user has the required permissions. See references/iam-policies.md for details.
Minimum required permissions:
  • obs:bucket:list
    — List buckets
  • obs:bucket:get
    — Get bucket attributes (capacity, object count)
  • obs:object:get
    — Read object information
  • obs:object:put
    — Upload objects

确保IAM用户拥有所需权限。详情请查看references/iam-policies.md
最小必需权限:
  • obs:bucket:list
    — 列出存储桶
  • obs:bucket:get
    — 获取存储桶属性(容量、对象数量)
  • obs:object:get
    — 读取对象信息
  • obs:object:put
    — 上传对象

Core Workflows

核心工作流程

Task 1: List Buckets with Capacity and Object Count

任务1:列出包含容量和对象数量的存储桶

List buckets via obsutil, then query bucket capacity and object count using CES capacity metrics or OBS API.
📄 Detailed steps → references/task-list-buckets-with-stats.md
通过obsutil列出存储桶,然后使用CES容量指标或OBS API查询存储桶容量和对象数量。
📄 详细步骤 → references/task-list-buckets-with-stats.md

Task 2: Upload Local File or Directory to Target Bucket

任务2:将本地文件或目录上传至目标存储桶

Upload files or directories to a specified OBS bucket using obsutil, supporting single file and directory upload.
📄 Detailed steps → references/task-upload-file.md
使用obsutil将文件或目录上传至指定OBS存储桶,支持单文件和目录上传。
📄 详细步骤 → references/task-upload-file.md

Task 3: Schedule Periodic Upload of Local Directory to Target Bucket

任务3:设置本地目录定期上传至目标存储桶的任务

Periodically upload a local directory to a specified OBS bucket incrementally via crontab scheduled task.
📄 Detailed steps → references/task-scheduled-upload.md

通过crontab定时任务,增量式定期将本地目录上传至指定OBS存储桶。
📄 详细步骤 → references/task-scheduled-upload.md

References

参考文档

DocumentDescription
task-list-buckets-with-stats.mdTask 1: List buckets with capacity and object count
task-upload-file.mdTask 2: Upload file or directory
task-scheduled-upload.mdTask 3: Scheduled upload
related-apis.mdAPI and CLI command details
iam-policies.mdIAM permission policies
obs-metrics.mdOBS CES monitoring metrics reference
verification-method.mdVerification steps
acceptance-criteria.mdCorrect/error pattern comparison
cli-installation-guide.mdCLI installation guide
troubleshooting.mdTroubleshooting and practical experience
文档描述
task-list-buckets-with-stats.md任务1:列出包含容量和对象数量的存储桶
task-upload-file.md任务2:上传文件或目录
task-scheduled-upload.md任务3:定时上传
related-apis.mdAPI和CLI命令详情
iam-policies.mdIAM权限策略
obs-metrics.mdOBS CES监控指标参考
verification-method.md验证步骤
acceptance-criteria.md正确/错误模式对比
cli-installation-guide.mdCLI安装指南
troubleshooting.md故障排除与实践经验