也是先source用户和租间

1、查看容器和存储的对象

[root@localhost ~(keystone_admin)]# swift list
[root@localhost ~(keystone_admin)]# swift list --lh
    0    0

$ swift list $container #显示某个容器的对象信息
2、查看状态信息

[root@localhost ~(keystone_admin)]# swift stat
   Account: AUTH_9387b24331da4daebac32a8ccd52dd4b
Containers: 0
   Objects: 0
     Bytes: 0
Content-Type: text/plain; charset=utf-8
X-Timestamp: 1384944092.11535
X-Put-Timestamp: 1384944092.11535
3、创建容器

[root@localhost ~(keystone_admin)]# swift post test
[root@localhost ~(keystone_admin)]# swift list --lh
    0    0 2013-11-20 10:42:16 test
    0    0

4、删除容器

[root@localhost ~(keystone_admin)]# swift delete test
[root@localhost ~(keystone_admin)]# swift list --lh
    0    0

$swift delete $container $object#删除某个容器里的某个对象


5、上传对象a、先创建个文件500M的

[root@localhost ~(keystone_admin)]# dd if=/dev/zero of=/tmp/example-500Mb bs=1M count=500
记录了500+0 的读入
记录了500+0 的写出
524288000字节(524 MB)已复制,0.258867 秒,2.0 GB/秒


b、上传到刚才创建的容器”test“中

[root@localhost ~(keystone_admin)]# swift upload test /tmp/example-500Mb 
tmp/example-500Mb


支持目录和多个文件

swift upload  $container $dir
swift upload $container file1 file2 ..


6、上传大文件时,可以用-S来分片(s for segment)

[root@localhost ~(keystone_admin)]# swift upload test -S 102400000 /tmp/example-500Mb 
tmp/example-500Mb segment 5
tmp/example-500Mb segment 0
tmp/example-500Mb segment 2
tmp/example-500Mb segment 1
tmp/example-500Mb segment 4
tmp/example-500Mb segment 3
tmp/example-500Mb


最终,文件对象会上传到"test"容器中,但也会增加一个“test_segments”的容器,里面放的就是文件分片时产生的各个小分片文件。

[root@localhost ~(keystone_admin)]# swift list --lh
    2   43 2013-11-20 10:42:16 test
    6 500M 2013-11-21 02:31:52 test_segments


[root@localhost ~(keystone_admin)]# swift list test --lh
   0 2013-11-21 02:41:32 tmp/example-500Mb
  43 2013-11-20 11:02:37 tmp/test.txt
  43

[root@localhost ~(keystone_admin)]# swift list test_segments --lh
 97M 2013-11-21 02:41:30 tmp/example-500Mb/1384944751.119769/524288000/102400000/00000000
 97M 2013-11-21 02:41:30 tmp/example-500Mb/1384944751.119769/524288000/102400000/00000001
 97M 2013-11-21 02:41:30 tmp/example-500Mb/1384944751.119769/524288000/102400000/00000002
 97M 2013-11-21 02:41:30 tmp/example-500Mb/1384944751.119769/524288000/102400000/00000003
 97M 2013-11-21 02:41:30 tmp/example-500Mb/1384944751.119769/524288000/102400000/00000004
 11M 2013-11-21 02:41:30 tmp/example-500Mb/1384944751.119769/524288000/102400000/00000005
500M



Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐