无法使用swift cli从bluemix上的对象存储容器下载文件

时间:2017-02-15 19:01:22

标签: swift ibm-cloud cloudfoundry object-storage

我在对象存储容器中有大量文件,我想备份那些试图下载它们。我已经完成了swift cli所需的所有设置并使用它。我有所有这些对象存储来自bluemix的详细信息

"auth_url": "https://identity.open.softlayer.com",
 "endpoint_url": "https://objectstorage.open.softlayer.com/v1/AUTH_",
 "password": "********",
  "projectId": "**************",
 "userId": "**********",
 "v3_auth_url":"https://identity.open.softlayer.com/v3/auth/tokens"

但是当我尝试使用上述数据下载时,swift命令无法正常工作

当我使用这个命令时,我得到了对象存储url和auth_token作为响应

swift auth --os-auth-url https://identity.open.softlayer.com/v3 --auth-version 3 --os-project
-id ***** --os-user-id ****** --os-password *******

然后我使用objectstorage url和auth_token获取容器列表但获得空响应

swift --os-auth-token ***** --os-storage-url ******* list

此外,我使用此命令从容器下载所有文件但没有工作

swift download --all containername --os-auth-url https://identity.open.softlayer.com/v3 --au
th-version 3 --os-project-id ****** --os-user-id ******* --os-password ******

请有一位了解此问题的人可以帮助下载这些文件 感谢

1 个答案:

答案 0 :(得分:2)

我发现使用适当的环境变量使Swift CLI更易于使用。首先定义这些

export OS_USER_ID='xxxxxxxx' #userId field in Bluemix UI
export OS_PASSWORD='xxxxxxxxx' # password field in Bluemix UI 
export OS_TENANT_ID='xxxxxxxxx' # projectId field in Bluemix data
export OS_AUTH_URL='https://identity.open.softlayer.com/v3'
export OS_REGION_NAME='dallas' #region (change as needed)
export OS_IDENTITY_API_VERSION=3 
export OS_AUTH_VERSION=3 

然后,您可以使用swift命令行而不需要很多--options。列出“fruit”容器的内容:

$: swift list fruit
apple
banana
orange

下载“水果”容器中的所有对象:

$: swift download fruit
banana [auth 0.455s, headers 0.919s, total 0.920s, 0.000 MB/s]
apple [auth 0.444s, headers 0.932s, total 0.933s, 0.000 MB/s]
orange [auth 0.498s, headers 1.104s, total 1.104s, 0.000 MB/s]

--all选项可用于下载所有内容(所有容器和对象)。它不用于单个容器下载。

    $: swift download --all
usercontainer/budgets.ods [auth 0.426s, headers 1.139s, total 1.140s, 0.033 MB/s]
usercontainer/get-pip.py [auth 0.440s, headers 1.109s, total 1.402s, 1.657 MB/s]
usercontainer/profile.jpg [auth 0.418s, headers 1.123s, total 5.240s, 0.415 MB/s]
fruit/orange [auth 0.000s, headers 0.064s, total 0.064s, 0.000 MB/s]
fruit/banana [auth 0.000s, headers 0.070s, total 0.070s, 0.000 MB/s]
fruit/apple [auth 0.000s, headers 0.077s, total 0.077s, 0.000 MB/s]