2015-06-01 41 views
0

现在我正在使用线程这样,但它很慢。我正在寻找上传一个文件夹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 
+0

只是一个很小的评论:你打电话的麻烦'除例外:pass'。 – tamasgal

+0

我只是要求安全,否则它永远不会失败。但速度很慢 – jayprakashstar

回答

0
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) 
相关问题