【问题标题】:How can I upload whole folder instead of one by one file in rackspace如何在机架空间中上传整个文件夹而不是一个一个文件
【发布时间】:2015-06-01 10:17:08
【问题描述】:

现在我正在使用这样的线程,但速度很慢。我要上传一个文件夹api。

def run(self):
        """Starts the uploading thread."""
        try:
            for file_name in self.files["thumbs"]:
                self.transfer_rackspace(file_name, self.container_thumbs)
        except Exception:
            pass
        try:
            for file_name in self.files["tiles"]:
                self.transfer_rackspace(file_name, self.container_tiles)
        except Exception:
            pass
        try:
            for file_name in self.files["cube"]:
                self.transfer_rackspace(file_name, self.container_photo)
        except Exception:
            pass
        try:
            for file_name in self.files["image"]:
                self.transfer_rackspace(file_name, self.container_photo)
        except Exception:
            pass

【问题讨论】:

  • 只是一个小小的评论:你在找except Exception: pass的麻烦。
  • 我只是要求安全,否则它永远不会失败。但它很慢

标签: python rackspace-cloudfiles


【解决方案1】:
pyrax.settings.set('identity_type', 'rackspace')
pyrax.set_credentials(config.app_config["cdn.account.name"],
                          config.app_config["cdn.account.key"])
rack_conn = pyrax.cloudfiles
rack_conn.upload_folder(folder_path, container)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-12-27
    • 1970-01-01
    • 1970-01-01
    • 2017-09-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多