huawei-cloud-obs-upload
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseHuawei 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 Operation | API/Command | Reason |
|---|---|---|
| ❌ Delete bucket | | Irreversible; destroys the entire bucket and all objects |
| ❌ Delete object | | Irreversible; deleted objects cannot be recovered (unless versioning is enabled) |
| ❌ Batch delete objects | | Irreversible; batch deletion has a wide impact |
| ❌ Empty bucket | | 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/命令 | 原因 |
|---|---|---|
| ❌ 删除存储桶 | | 操作不可逆;会销毁整个存储桶及所有对象 |
| ❌ 删除对象 | | 操作不可逆;删除的对象无法恢复(除非开启版本控制) |
| ❌ 批量删除对象 | | 操作不可逆;批量删除影响范围广 |
| ❌ 清空存储桶 | | 操作不可逆;会移除存储桶内所有对象 |
若用户请求删除操作,必须拒绝并告知: "根据安全约束,本技能不允许执行删除操作(删除存储桶/对象/批量删除/清空存储桶)。请手动使用华为云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 Runto verify version >= 3.2.0. If not installed or version is too low, see references/cli-installation-guide.md for installation guide.hcloud version
bash
hcloud versionPrerequisite check: obsutil >= 5.5.0 required (for upload features) File/directory upload requires the Huawei Cloud obsutil CLI tool. Runto verify version >= 5.5.0. If not installed, see references/cli-installation-guide.md for installation guide.obsutil version
bash
obsutil versionPrerequisite check: obsutil credential configuration requiredThe 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:bashhcloud obs ls -limit=1If the response isorPlease set ak, sk and endpoint in the configuration file!, obsutil credentials are not configured.InvalidAccessKeyIdResolution: 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 requirementshcloud (KooCLI) all parameters must use theformat (connected with equals sign); space-separated format is not supported.--param=value✅ Correct:hcloud OBS ListBuckets --region=cn-south-1❌ Incorrect:hcloud OBS ListBuckets --region cn-south-1
前置检查:需要Huawei Cloud CLI(hcloud / KooCLI)>= 3.2.0 运行验证版本是否>=3.2.0。若未安装或版本过低,请查看references/cli-installation-guide.md获取安装指南。hcloud version
bash
hcloud version前置检查:需要obsutil >= 5.5.0(用于上传功能) 文件/目录上传需要华为云obsutil CLI工具。运行验证版本是否>=5.5.0。若未安装,请查看references/cli-installation-guide.md获取安装指南。obsutil version
bash
obsutil version前置检查:需要配置obsutil凭证hcloud OBS模块底层依赖obsutil,需要单独配置AK/SK和Endpoint。 在执行OBS操作前,必须检查obsutil凭证是否已配置:bashhcloud obs ls -limit=1若返回或Please set ak, sk and endpoint in the configuration file!,则obsutil凭证未配置。InvalidAccessKeyId解决方法:提供以下示例命令,让用户在终端中配置(请勿要求用户在对话中直接提供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
to pass plaintext credential valueshcloud configure set- 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 credentialsIf a user attempts to provide AK/SK directly (e.g., "my AK is xxx, SK is yyy"):
- Stop immediately - Do not execute any commands
- 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.- Do not continue executing any Huawei Cloud operations until credentials are configured
Check CLI configuration:bashhcloud configure listCheck 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"):
- 立即停止 - 不要执行任何命令
- 礼貌拒绝并返回以下信息:
为了账户安全,请不要在对话中直接提供华为云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> 配置完成后,请重试您的请求。- 在凭证配置完成前,不要继续执行任何华为云操作
检查CLI配置:bashhcloud 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:
- — List buckets
obs:bucket:list - — Get bucket attributes (capacity, object count)
obs:bucket:get - — Read object information
obs:object:get - — Upload objects
obs:object:put
确保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
参考文档
| Document | Description |
|---|---|
| task-list-buckets-with-stats.md | Task 1: List buckets with capacity and object count |
| task-upload-file.md | Task 2: Upload file or directory |
| task-scheduled-upload.md | Task 3: Scheduled upload |
| related-apis.md | API and CLI command details |
| iam-policies.md | IAM permission policies |
| obs-metrics.md | OBS CES monitoring metrics reference |
| verification-method.md | Verification steps |
| acceptance-criteria.md | Correct/error pattern comparison |
| cli-installation-guide.md | CLI installation guide |
| troubleshooting.md | Troubleshooting and practical experience |
| 文档 | 描述 |
|---|---|
| task-list-buckets-with-stats.md | 任务1:列出包含容量和对象数量的存储桶 |
| task-upload-file.md | 任务2:上传文件或目录 |
| task-scheduled-upload.md | 任务3:定时上传 |
| related-apis.md | API和CLI命令详情 |
| iam-policies.md | IAM权限策略 |
| obs-metrics.md | OBS CES监控指标参考 |
| verification-method.md | 验证步骤 |
| acceptance-criteria.md | 正确/错误模式对比 |
| cli-installation-guide.md | CLI安装指南 |
| troubleshooting.md | 故障排除与实践经验 |