2015-06-01 29 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) 
相關問題