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