Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/323.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 使用swiftclient将大文件直接流式传输到Openstack_Python_Urllib_Openstack Swift - Fatal编程技术网

Python 使用swiftclient将大文件直接流式传输到Openstack

Python 使用swiftclient将大文件直接流式传输到Openstack,python,urllib,openstack-swift,Python,Urllib,Openstack Swift,我需要将文件从文件存储服务上传到OSS,以及Rabbit MQ队列。目前,我正在使用urllib下载文件,然后使用python swiftclient将它们上载到OSS。此解决方案适用于较小的文件,但对于较大的文件,队列会失去连接,因为它假定使用者已死亡(因为它不会返回心跳) 这是我当前的上传/下载代码: def download_file(file_name, url): urllib.urlretrieve(url, file_name) def upload_file(file_

我需要将文件从文件存储服务上传到OSS,以及Rabbit MQ队列。目前,我正在使用urllib下载文件,然后使用python swiftclient将它们上载到OSS。此解决方案适用于较小的文件,但对于较大的文件,队列会失去连接,因为它假定使用者已死亡(因为它不会返回心跳)

这是我当前的上传/下载代码:

def download_file(file_name, url):
    urllib.urlretrieve(url, file_name)

def upload_file(file_name):
    with open(file_name, 'r') as myfile:
        conn.put_object(container, file_name, contents=myfile.read())
我想知道有没有一种方法可以通过避免将文件下载到磁盘来加速这个过程。可能是在某个变量中将块下载到内存中,然后直接流式传输到OSS上

谢谢您的时间:)