123456789101112131415161718 |
- def upload_files(self, list_of_files):
- self.count = 0
- print("Sample of file to be uploaded to Google storage are \t {}".format(
- list_of_files))
- bucket = self.__storage_client.get_bucket(self.__bucket)
- for each_file in tqdm(list_of_files):
- try:
- blob_name = os.path.split(each_file)[-1]
- blob = bucket.blob(blob_name)
- blob.upload_from_filename(
- each_file) # .upload_file from google cloud api package uploads file to google storage
- self.count += 1
- except Exception as e:
- print("Failed to upload file {} \n{}".format(each_file, e))
- print("Total file succefully uploaded:\t {}".format(self.count))
- return True
|