更新时间:2024-02-29 GMT+08:00

快速使用

本章节以Linux操作系统为例,介绍如何通过obsutil在OBS上完成基本的数据存取操作,具体操作流程如图1所示。

图1 obsutil快速使用流程

前提条件

  • 已获取到obsutil工具,并完成了初始化配置
  • 已进入obsutil工具所在目录。

操作步骤

  1. 运行./obsutil mb obs://bucket-test命令,创建一个名为bucket-test的新桶。

    ./obsutil mb obs://bucket-test
    
    Create bucket [bucket-test] successfully!

  2. 运行./obsutil cp /temp/test.txt obs://bucket-test/test.txt命令,将本地test.txt文件上传至bucket-test桶中。

    ./obsutil cp /temp/test.txt obs://bucket-test/test.txt
    
    Parallel:      5                   Jobs:          5
    Threshold:     52428800            PartSize:      5242880
    Exclude:                           Include:
    VerifyLength:  false               VerifyMd5:     false
    CheckpointDir: /temp/.obsutil_checkpoint
    
    test.txt:[==============================================] 100.00% 48.47 KB/s 0s
    Upload successfully, 4.44KB, /temp/test.txt --> obs://bucket-test1/test.txt

    如果想要将本地test文件夹上传OBS桶中,对应命令是:

    ./obsutil cp /test/ obs://bucket-test -r -f

  3. 运行./obsutil cp obs://bucket-test/test.txt /temp/test1.txt命令,将bucket-test桶中的test.txt对象下载至本地。

    ./obsutil cp obs://bucket-test/test.txt /temp/test1.txt
    
    Parallel:      5                   Jobs:          5
    Threshold:     52428800            PartSize:      5242880
    Exclude:                           Include:
    VerifyLength:  false               VerifyMd5:     false
    CheckpointDir: /temp/.obsutil_checkpoint
    
    test.txt:[=============================================] 100.00% 775.52 KB/s 0s
    Download successfully, 4.44KB, obs://bucket-test1/test.txt --> /temp/test1.txt

    如果想要将OBS桶内test目录下载至本地temp文件夹中,对应命令是:

    ./obsutil cp obs://bucket-test/test /temp -r -f

  4. 运行./obsutil rm obs://bucket-test/test.txt -f命令,在bucket-test桶中删除test.txt对象。

    ./obsutil rm obs://bucket-test/test.txt -f
    
    Delete object [test.txt] in the bucket [bucket-test] successfully!

  5. 运行./obsutil rm obs://bucket-test -f命令,删除bucket-test桶。

    ./obsutil rm obs://bucket-test -f
    
    Delete bucket [bucket-test] successfully!