无法从 swift tempurl 获取对象
can't get object from swift tempurl
我在 VirtualBox 上设置了 SAIO,想检查 url 功能在 Swift 上的工作情况。
这里是我在容器"testCon"下调用test.txt创建的对象,可以看到内容swift列出对象
swift@swift-VirtualBox:~/bin$ curl -X GET -H 'X-Auth-Token: AUTH_tkba199b23eeec4998b7119d2c9c903216' http://127.0.0.1:8080/v1/AUTH_test/testCon/test.txt
this is a test
swift@swift-VirtualBox:~/bin$ swift -A http://127.0.0.1:8080/auth/v1.0 -U test:tester -K testing list testCon
test.txt
我按照 link (http://ceph.com/docs/master/radosgw/swift/tempurl/) 为临时 url
设置临时 url 键
swift@swift-VirtualBox:~/bin$ curl -X POST -H 'X-Auth-Token: AUTH_tkba199b23eeec4998b7119d2c9c903216' -H 'X-Account-Meta-Temp-URL-Key: secret' http://127.0.0.1:8080/v1/AUTH_test/testCon/test.txt
<html><h1>Accepted</h1><p>The request is accepted for processing.</p></html>swift@swift-VirtualBox:~/bin$
swift@swift-VirtualBox:~/bin$ swift -A http://127.0.0.1:8080/auth/v1.0 -U test:tester -K testing post -m "Temp-URL-Key:secret"
并按照 python 示例生成温度 url links
import hmac
from hashlib import sha1
from time import time
method = 'GET'
host = "http://127.0.0.1:8080"
duration_in_seconds = 300 # Duration for which the url is valid
expires = int(time() + duration_in_seconds)
path = '/v1/AUTH_test/testCon/test.txt'
key = 'secret'
hmac_body = '%s\n%s\n%s' % (method, expires, path)
hmac_body = hmac.new(key, hmac_body, sha1).hexdigest()
sig = hmac.new(key, hmac_body, sha1).hexdigest()
rest_uri = "{host}{path}?temp_url_sig={sig}&temp_url_expires={expires}".format(
host=host, path=path, sig=sig, expires=expires)
print rest_uri
但是当我将 link 放入 cli 时,它总是显示:没有那个文件或目录
swift@swift-VirtualBox:~/bin$ http://127.0.0.1:8080/v1/AUTH_test/testCon/test.txt?temp_url_sig=83fa35362613a18c2ca0b48203ccda61d2229daa&temp_url_expires=1439938672
[1] 6125
swift@swift-VirtualBox:~/bin$ -bash: http://127.0.0.1:8080/v1/AUTH_test/testCon/test.txt?temp_url_sig=83fa35362613a18c2ca0b48203ccda61d2229daa: **No such file or directory**
有人可以帮忙吗?
请给我一些建议?
谢谢百万!
您需要浏览到 python 脚本生成的 URL。
您可以在网络浏览器中或使用命令行中的 curl 命令执行此操作:
curl http://127.0.0.1:8080/v1/AUTH_test/testCon/test.txt?temp_url_sig=83fa35362613a18c2ca0b48203ccda61d2229daa&temp_url_expires=1439938672
仅将 url 单独放在命令行上不会执行任何操作。
还有其他人可以为 tempURL 问题提供有用的答案吗?
这是您可以看到的 swift 统计数据,tempurl 密钥应该在那里。
swift@swift-VirtualBox:~$ swift -A http://127.0.0.1:8080/auth/v1.0 -U test:tester -K testing stat
Account: AUTH_test
Containers: 1
Objects: 0
Bytes: 0
Containers in policy "gold": 1
Objects in policy "gold": 0
Bytes in policy "gold": 0
Meta X-Account-Meta-Temp-Url-Key: secret
Meta Temp-Url-Key: secret
X-Timestamp: 1439949170.11921
X-Trans-Id: tx38b5a254caf34023b96c3-0055d3e3e0
Content-Type: text/plain; charset=utf-8
Accept-Ranges: bytes
swift@swift-VirtualBox:~$ swift -A http://127.0.0.1:8080/auth/v1.0 -U test:tester -K testing stat testCon
Account: AUTH_test
Container: testCon
Objects: 1
Bytes: 15
Read ACL:
Write ACL:
Sync To:
Sync Key:
Meta X-Account-Meta-Temp-Url-Key: secret
Accept-Ranges: bytes
X-Storage-Policy: gold
X-Timestamp: 1439949251.62009
X-Trans-Id: tx80638d6e3bb24764945fb-0055d3e3e6
Content-Type: text/plain; charset=utf-8
swift@swift-VirtualBox:~$ swift -A http://127.0.0.1:8080/auth/v1.0 -U test:tester -K testing stat testCon test.txt
Account: AUTH_test
Container: testCon
Object: test.txt
Content Type: text/plain
Content Length: 15
Last Modified: Wed, 19 Aug 2015 02:03:04 GMT
ETag: 81967071826aa902b0fa890876499cbb
Meta X-Account-Meta-Temp-Url-Key: secret
Accept-Ranges: bytes
X-Timestamp: 1439949783.34589
X-Trans-Id: tx8d4566c37c9b4f598193e-0055d3e3ee
我尝试了浏览器和 curl + link,它们都不适合我。
swift@swift-VirtualBox:~$ curl http://127.0.0.1:8080/testCon/test.txt?temp_url_sig=e005d33b515a2e7900ff58f86e062f8a5682217f&temp_url_expires=1439952878
[1] 18540
swift@swift-VirtualBox:~$ 401 Unauthorized: Temp URL invalid
swift@swift-VirtualBox:~$ curl http://127.0.0.1:8080/v1/AUTH_test/testCon/test.txt?temp_url_sig=b65dae8902026c3ade58d91a2f4c4ee135d564b0&temp_url_expires=1439952980
[1] 18542
swift@swift-VirtualBox:~$ 401 Unauthorized: Temp URL invalid
我不确定 python 中的路径是否正确,因为我看到人们有两个不同的建议,但包括 /V1/Auth_User/container/object 看起来是必要的。
import hmac
from hashlib import sha1
from time import time
method = 'GET'
#host = 'https://objectstore.example.com'
host = "http://127.0.0.1:8080"
#host = "http://127.0.0.1:8080/testCon/test.txt"
duration_in_seconds = 3000 # Duration for which the url is valid
expires = int(time() + duration_in_seconds)
#path = '/v1/your-bucket/your-object'
#path = '/v1/tempfolder/test.txt'
path = '/v1/AUTH_test/testCon/test.txt'
key = 'secret'
#key2 = 'secret2'
hmac_body = '%s\n%s\n%s' % (method, expires, path)
hmac_body = hmac.new(key, hmac_body, sha1).hexdigest()
#hmac_body = hmac.new(key, key2, hmac_body, sha1).hexdigest()
sig = hmac.new(key, hmac_body, sha1).hexdigest()
rest_uri = "{host}{path}?temp_url_sig={sig}&temp_url_expires={expires}".format(
#host=host, path="", sig=sig, expires=expires)
host=host, path=path, sig=sig, expires=expires)
print rest_uri
如果您能与我分享建议,那就太好了。
我在 VirtualBox 上设置了 SAIO,想检查 url 功能在 Swift 上的工作情况。
这里是我在容器"testCon"下调用test.txt创建的对象,可以看到内容swift列出对象
swift@swift-VirtualBox:~/bin$ curl -X GET -H 'X-Auth-Token: AUTH_tkba199b23eeec4998b7119d2c9c903216' http://127.0.0.1:8080/v1/AUTH_test/testCon/test.txt
this is a test
swift@swift-VirtualBox:~/bin$ swift -A http://127.0.0.1:8080/auth/v1.0 -U test:tester -K testing list testCon
test.txt
我按照 link (http://ceph.com/docs/master/radosgw/swift/tempurl/) 为临时 url
设置临时 url 键swift@swift-VirtualBox:~/bin$ curl -X POST -H 'X-Auth-Token: AUTH_tkba199b23eeec4998b7119d2c9c903216' -H 'X-Account-Meta-Temp-URL-Key: secret' http://127.0.0.1:8080/v1/AUTH_test/testCon/test.txt
<html><h1>Accepted</h1><p>The request is accepted for processing.</p></html>swift@swift-VirtualBox:~/bin$
swift@swift-VirtualBox:~/bin$ swift -A http://127.0.0.1:8080/auth/v1.0 -U test:tester -K testing post -m "Temp-URL-Key:secret"
并按照 python 示例生成温度 url links
import hmac
from hashlib import sha1
from time import time
method = 'GET'
host = "http://127.0.0.1:8080"
duration_in_seconds = 300 # Duration for which the url is valid
expires = int(time() + duration_in_seconds)
path = '/v1/AUTH_test/testCon/test.txt'
key = 'secret'
hmac_body = '%s\n%s\n%s' % (method, expires, path)
hmac_body = hmac.new(key, hmac_body, sha1).hexdigest()
sig = hmac.new(key, hmac_body, sha1).hexdigest()
rest_uri = "{host}{path}?temp_url_sig={sig}&temp_url_expires={expires}".format(
host=host, path=path, sig=sig, expires=expires)
print rest_uri
但是当我将 link 放入 cli 时,它总是显示:没有那个文件或目录
swift@swift-VirtualBox:~/bin$ http://127.0.0.1:8080/v1/AUTH_test/testCon/test.txt?temp_url_sig=83fa35362613a18c2ca0b48203ccda61d2229daa&temp_url_expires=1439938672
[1] 6125
swift@swift-VirtualBox:~/bin$ -bash: http://127.0.0.1:8080/v1/AUTH_test/testCon/test.txt?temp_url_sig=83fa35362613a18c2ca0b48203ccda61d2229daa: **No such file or directory**
有人可以帮忙吗? 请给我一些建议?
谢谢百万!
您需要浏览到 python 脚本生成的 URL。 您可以在网络浏览器中或使用命令行中的 curl 命令执行此操作:
curl http://127.0.0.1:8080/v1/AUTH_test/testCon/test.txt?temp_url_sig=83fa35362613a18c2ca0b48203ccda61d2229daa&temp_url_expires=1439938672
仅将 url 单独放在命令行上不会执行任何操作。
还有其他人可以为 tempURL 问题提供有用的答案吗? 这是您可以看到的 swift 统计数据,tempurl 密钥应该在那里。
swift@swift-VirtualBox:~$ swift -A http://127.0.0.1:8080/auth/v1.0 -U test:tester -K testing stat
Account: AUTH_test
Containers: 1
Objects: 0
Bytes: 0
Containers in policy "gold": 1
Objects in policy "gold": 0
Bytes in policy "gold": 0
Meta X-Account-Meta-Temp-Url-Key: secret
Meta Temp-Url-Key: secret
X-Timestamp: 1439949170.11921
X-Trans-Id: tx38b5a254caf34023b96c3-0055d3e3e0
Content-Type: text/plain; charset=utf-8
Accept-Ranges: bytes
swift@swift-VirtualBox:~$ swift -A http://127.0.0.1:8080/auth/v1.0 -U test:tester -K testing stat testCon
Account: AUTH_test
Container: testCon
Objects: 1
Bytes: 15
Read ACL:
Write ACL:
Sync To:
Sync Key:
Meta X-Account-Meta-Temp-Url-Key: secret
Accept-Ranges: bytes
X-Storage-Policy: gold
X-Timestamp: 1439949251.62009
X-Trans-Id: tx80638d6e3bb24764945fb-0055d3e3e6
Content-Type: text/plain; charset=utf-8
swift@swift-VirtualBox:~$ swift -A http://127.0.0.1:8080/auth/v1.0 -U test:tester -K testing stat testCon test.txt
Account: AUTH_test
Container: testCon
Object: test.txt
Content Type: text/plain
Content Length: 15
Last Modified: Wed, 19 Aug 2015 02:03:04 GMT
ETag: 81967071826aa902b0fa890876499cbb
Meta X-Account-Meta-Temp-Url-Key: secret
Accept-Ranges: bytes
X-Timestamp: 1439949783.34589
X-Trans-Id: tx8d4566c37c9b4f598193e-0055d3e3ee
我尝试了浏览器和 curl + link,它们都不适合我。
swift@swift-VirtualBox:~$ curl http://127.0.0.1:8080/testCon/test.txt?temp_url_sig=e005d33b515a2e7900ff58f86e062f8a5682217f&temp_url_expires=1439952878
[1] 18540
swift@swift-VirtualBox:~$ 401 Unauthorized: Temp URL invalid
swift@swift-VirtualBox:~$ curl http://127.0.0.1:8080/v1/AUTH_test/testCon/test.txt?temp_url_sig=b65dae8902026c3ade58d91a2f4c4ee135d564b0&temp_url_expires=1439952980
[1] 18542
swift@swift-VirtualBox:~$ 401 Unauthorized: Temp URL invalid
我不确定 python 中的路径是否正确,因为我看到人们有两个不同的建议,但包括 /V1/Auth_User/container/object 看起来是必要的。
import hmac
from hashlib import sha1
from time import time
method = 'GET'
#host = 'https://objectstore.example.com'
host = "http://127.0.0.1:8080"
#host = "http://127.0.0.1:8080/testCon/test.txt"
duration_in_seconds = 3000 # Duration for which the url is valid
expires = int(time() + duration_in_seconds)
#path = '/v1/your-bucket/your-object'
#path = '/v1/tempfolder/test.txt'
path = '/v1/AUTH_test/testCon/test.txt'
key = 'secret'
#key2 = 'secret2'
hmac_body = '%s\n%s\n%s' % (method, expires, path)
hmac_body = hmac.new(key, hmac_body, sha1).hexdigest()
#hmac_body = hmac.new(key, key2, hmac_body, sha1).hexdigest()
sig = hmac.new(key, hmac_body, sha1).hexdigest()
rest_uri = "{host}{path}?temp_url_sig={sig}&temp_url_expires={expires}".format(
#host=host, path="", sig=sig, expires=expires)
host=host, path=path, sig=sig, expires=expires)
print rest_uri
如果您能与我分享建议,那就太好了。