Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/302.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使用tornado.httpclient.asycnhttpclient将数据上载到对象存储?_Python_Tornado_Openstack - Fatal编程技术网

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

Python 如何使用tornado.httpclient.asycnhttpclient将数据上载到对象存储?,python,tornado,openstack,Python,Tornado,Openstack,我试图使用tornado aysnchttpclient上载一些数据,但它不起作用: 我得到的错误是HTTP 404:找不到, 以下是我使用的一些代码: import os import tornado.web from tornado.ioloop import IOLoop from tornado.httpclient import AsyncHTTPClient, HTTPRequest def send_files(): datfile = None with

我试图使用tornado aysnchttpclient上载一些数据,但它不起作用: 我得到的错误是HTTP 404:找不到, 以下是我使用的一些代码:

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')

好的,我想出来了,显然与命令行swift客户端不同,我必须首先创建容器。就这样。