tasks_5.py 698 B

123456789101112131415
  1. def upload_to_s3_bucket(self, file_path):
  2. self.total = os.stat(file_path).st_size
  3. print("Uploading to s3 bucket....")
  4. s3 = self.session.resource('s3')
  5. try:
  6. self.update_status("started_at", datetime.datetime.now())
  7. s3.meta.client.upload_file(
  8. file_path, self.bucket, self.filename, Callback=self.upload_progress)
  9. self.update_status("status", "Done")
  10. self.update_status("done_at", datetime.datetime.now())
  11. print("Uploading to s3 bucket done")
  12. except ClientError as e:
  13. logging.error(e)
  14. self.update_status("Failed")
  15. self.delete_downloaded_file(file_path)