Get the size of file path, same usage as `os.path.getsize` Example: from easycv.file import io io.access_oss(your oss config) # only oss file need, refer to `IO.access_oss` size = io.size('oss://bucket/file.txt') print(size) A
(self, path: str)
| 730 | return bucket.get_object_meta(path).headers['Last-Modified'] |
| 731 | |
| 732 | def size(self, path: str) -> int: |
| 733 | """ |
| 734 | Get the size of file path, same usage as `os.path.getsize` |
| 735 | |
| 736 | Example: |
| 737 | from easycv.file import io |
| 738 | io.access_oss(your oss config) # only oss file need, refer to `IO.access_oss` |
| 739 | size = io.size('oss://bucket/file.txt') |
| 740 | print(size) |
| 741 | Args: |
| 742 | path: local or oss path. |
| 743 | Return: size of file in bytes |
| 744 | """ |
| 745 | if not is_oss_path(path): |
| 746 | return super().size(path) |
| 747 | bucket, path = self._get_bucket_obj_and_path(path) |
| 748 | return int(bucket.get_object_meta(path).headers['Content-Length']) |
| 749 | |
| 750 | |
| 751 | class OSSFile: |