bucketstore-1.py 550 B

12345678910
  1. def upload(self, file: Union[str, BinaryIO], callback: Callable = None) -> None:
  2. """upload the file or file obj at the given path to this key"""
  3. _upload = self.bucket._boto_s3.meta.client.upload_fileobj
  4. if isinstance(file, str):
  5. if not os.path.isfile(file):
  6. raise Exception("file does not exist!")
  7. with open(file, "rb") as data:
  8. _upload(data, self.bucket.name, self.name, Callback=callback)
  9. elif isinstance(file, io.IOBase):
  10. _upload(file, self.bucket.name, self.name, Callback=callback)