1

我试图使用龙卷风 aysnchttpclient 上传一些数据但它不工作:我得到的错误是HTTP 404: Not Found,这是我使用的一些代码:

import os
import  tornado.web
from tornado.ioloop import IOLoop
from tornado.httpclient import AsyncHTTPClient, HTTPRequest   

def send_files():
    datfile = None
    with open('test_data/1.dat','rb') as datf:
        datfile =  datf.read()
    ur = 'http://swiftauth:8080/v1/AUTH_test'+'/'+'cont'+'/'+'loldat'
    print ('sending  to %s'% ur )
    pot = HTTPRequest(  ur , method='PUT', 
                        headers={'X-Auth-Token':'AUTH_tkbfa9045f97c040fbbd10f0bd0970d78d',
                                  'Content-Type': 'text/plain'},
                        body =datfile,allow_nonstandard_methods=True )
    http_put_client.fetch(pot, handle_put_rep)

def handle_put_rep(response):
    if response.error:
        print ('this is ', response.error, 'type of error')
    else:
        print ('success in put',response.headers)



http_put_client = AsyncHTTPClient() 
send_files() 
loop = IOLoop.instance()
if __name__ == "__main__":
    loop.start()

一切似乎都很好,我可以使用 asyncclient 来获取身份验证令牌,但不能上传,并且命令行 swift 客户端正在工作,所有这些都使用相同的凭据。

('AUTH_tkbfa9045f97c040fbbd10f0bd0970d78d', 'AUTH_TOKEN')
('http://swiftauth:8080/v1/AUTH_test', 'URL')
('swiftauth:8080', 'CONNECTION_ENDPOINT')
('/v1/AUTH_test/Tor', 'CONTAINER_PATH')
4

0 回答 0