Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
On this page

Show all

Upload

Updated on 2025-02-07 GMT+08:00

All commands in this section use the Linux operating system as an example to describe how to upload files.

Assume that a local folder is in the following structure:

└── src1
    ├── src2
        ├── test1.txt
        └── test2.txt
    ├── src3
    └── test3.txt

Based on the preceding folder structure, different upload scenarios require different commands.

  • To upload the test3.txt file in the local src1 folder to the root directory of bucket bucket-test, the command is as follows:
    ./obsutil cp /src1/test3.txt  obs://bucket-test

    After the upload completes, the following object is generated in the bucket:

    ./obs://bucket-test/test3.txt
  • To upload the test3.txt file in the local src1 folder to the root directory of bucket bucket-test and rename it to aaa.txt, the command is as follows:
    ./obsutil cp /src1/test3.txt  obs://bucket-test/aaa.txt

    After the upload completes, the following object is generated in the bucket:

    ./obs://bucket-test/aaa.txt
  • To upload the test3.txt file in the local src1 folder to the src folder in bucket bucket-test, the command is as follows:
    ./obsutil cp /src1/test3.txt  obs://bucket-test/src/

    After the upload completes, the following object is generated in the bucket:

    ./obs://bucket-test/src/test3.txt
  • To recursively upload the entire local src2 folder to the root directory of bucket bucket-test in force mode, the command is as follows:
    ./obsutil cp /src1/src2  obs://bucket-test -r -f

    After the upload completes, the following objects are generated in the bucket:

    obs://bucket-test/src2/
    obs://bucket-test/src2/test1.txt
    obs://bucket-test/src2/test2.txt
  • To recursively upload the entire local src1 folder to the src folder in bucket bucket-test in force mode, the command is as follows:
    ./obsutil cp /src1  obs://bucket-test/src -r -f

    After the upload completes, the following objects are generated in the bucket:

    obs://bucket-test/src/src1/
    obs://bucket-test/src/src1/src2/
    obs://bucket-test/src/src1/src2/test1.txt
    obs://bucket-test/src/src1/src2/test2.txt
    obs://bucket-test/src/src1/src3/
    obs://bucket-test/src/src1/test3.txt
  • To recursively upload the all files and subfolders in the local src1 folder to the src folder in bucket bucket-test in force mode, the command is as follows:
    ./obsutil cp /src1  obs://bucket-test/src -r -f -flat

    After the upload completes, the following objects are generated in the bucket:

    obs://bucket-test/src/
    obs://bucket-test/src/src2/
    obs://bucket-test/src/src2/test1.txt
    obs://bucket-test/src/src2/test2.txt
    obs://bucket-test/src/src3/
    obs://bucket-test/src/test3.txt
  • To upload the file1 file to the bucket-test bucket, and resume the upload if the upload fails, run the following commands:
    ./obsutil cp /file1  obs://bucket-test/file -f

    The upload fails. The command output is as follows:

    ./obsutil cp /file1 obs://bucket-test/file -f
    
    Parallel:      3                   Jobs:          3
    Threshold:     524288000           PartSize:      5242880
    VerifyLength:  false               VerifyMd5:     false
    CheckpointDir: xxxx
    
    [=================================__________________] 66.08% ?/s 3.35GB/4.88GB ?

    Run the preceding command again to resume the upload. The command output is as follows:

    obsutil cp /file1 obs://bucket-test/file -f
    Parallel:      3                   Jobs:          3
    Threshold:     524288000           PartSize:      5242880
    VerifyLength:  false               VerifyMd5:     false
    CheckpointDir: xxxx
    
    [====================================================] 100% 307.42MB/s 4.88GB/4.88GB 5.308s
    Upload successfully, 4.88GB, n/a, /file1 --> obs://bucket-test/file, cost [6325], status [200], request id [xxxxx]
  • To incrementally upload all files from the local src1 folder to the src directory of bucket bucket-test, the command is as follows:
    ./obsutil cp /src1  obs://bucket-test/src -f -r -u

    Four objects are successfully uploaded, one of which is a new object. The command output contains Skip count.

    ./obsutil cp /src1 obs://bucket-test/src -f -r -u
    Start at 2024-10-08 02:00:18.8906532 +0000 UTC
    
    Parallel:      5                   Jobs:          5
    Threshold:     50.00MB             PartSize:      auto
    VerifyLength:  false               VerifyMd5:     false
    CheckpointDir: xxxx
    Task id: 6a97974a-7929-4188-9736-fcd637d16584
    OutputDir: xxxx
    [====================================================] 100% tps:0.00 ?/s 2.09KB/2.09KB 5ms
    Succeed count:   4         Failed count:    0         Skip count:      3
    Succeed bytes:   2.09KB
    Metrics [max cost:6 ms, min cost:6 ms, average cost:1.50 ms, average tps:52.63, transferred size :2.09KB]
  • Run the following command to exclude the src2 folder (including all files and folders contained) when uploading the src1 folder:
    ./obsutil cp /src1  obs://bucket-test/src -exclude "*src1/src2*" -f -r -mf

    Five objects are successfully uploaded, and the upload information contains exclude and the specific content.

    ./obsutil cp /src1  obs://bucket-test/src -exclude "*src1/src2*" -f -r -mf
    Start at 2024-10-08 02:04:27.7752009 +0000 UTC
    Parallel:      5                   Jobs:          5
    Threshold:     50.00MB             PartSize:      auto
    VerifyLength:  false               VerifyMd5:     false
    Exclude:       *src1/src2*
    Include:
    CheckpointDir: xxxx
    OutputDir: xxxx
    
    [====================================================] 100.00% tps:35.82 ?/s 5/5 2.39KB/2.39KB 340ms
    Succeed count:   3         Failed count:    0
    Succeed bytes:   2.39KB
    Metrics [max cost:338 ms, min cost:91 ms, average cost:240.40 ms, average tps:14.62, transferred size:2.39KB]

    After the upload completes, the following objects are generated in the bucket:

    obs://bucket-test/src/src1/
    obs://bucket-test/src/src1/src3/
    obs://bucket-test/src/src1/test3.txt
NOTE:

Resumable upload is available only for large files. Specifically, the file size is greater than 5 GB or the file size is greater than the threshold (50 MB by default).

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback