如何使用tornado.httpclient.asycnhttpclient将数据上传到对象存储?

时间:2013-09-18 13:30:39

标签: python tornado openstack

即时尝试使用龙卷风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')

0 个答案:

没有答案