Returns file statistics for a given path.
(self, filename)
| 403 | client.put_object(Body="", Bucket=bucket, Key=path) |
| 404 | |
| 405 | def stat(self, filename): |
| 406 | """Returns file statistics for a given path.""" |
| 407 | # NOTE: Size of the file is given by ContentLength from S3, |
| 408 | # but we convert to .length |
| 409 | client = boto3.client("s3", endpoint_url=self._s3_endpoint) |
| 410 | bucket, path = self.bucket_and_path(filename) |
| 411 | try: |
| 412 | obj = client.head_object(Bucket=bucket, Key=path) |
| 413 | return StatData(obj["ContentLength"]) |
| 414 | except botocore.exceptions.ClientError as exc: |
| 415 | if exc.response["Error"]["Code"] == "404": |
| 416 | raise errors.NotFoundError(None, None, "Could not find file") |
| 417 | else: |
| 418 | raise |
| 419 | |
| 420 | |
| 421 | class FSSpecFileSystem: |