Get checksum for S3 object or directory. Computes a checksum for the specified S3 path. For individual objects, returns the ETag converted to an integer. For directories, returns a checksum based on the directory's tokenized representation. Args: path: S
(self, path: str, **kwargs)
| 1343 | callback.relative_update(len(data)) |
| 1344 | |
| 1345 | def checksum(self, path: str, **kwargs): |
| 1346 | """Get checksum for S3 object or directory. |
| 1347 | |
| 1348 | Computes a checksum for the specified S3 path. For individual objects, |
| 1349 | returns the ETag converted to an integer. For directories, returns a |
| 1350 | checksum based on the directory's tokenized representation. |
| 1351 | |
| 1352 | Args: |
| 1353 | path: S3 path (s3://bucket/key) to get checksum for. |
| 1354 | **kwargs: Additional arguments including: |
| 1355 | refresh: If True, refresh cached info before computing checksum. |
| 1356 | |
| 1357 | Returns: |
| 1358 | Integer checksum value derived from S3 ETag or directory token. |
| 1359 | |
| 1360 | Note: |
| 1361 | For multipart uploads, ETag format is different and only the first |
| 1362 | part before the dash is used for checksum calculation. |
| 1363 | """ |
| 1364 | refresh = kwargs.pop("refresh", False) |
| 1365 | info = self.info(path, refresh=refresh) |
| 1366 | if info.get("type") != S3ObjectType.S3_OBJECT_TYPE_DIRECTORY: |
| 1367 | return int(info.get("etag").strip('"').split("-")[0], 16) |
| 1368 | return int(tokenize(info), 16) |
| 1369 | |
| 1370 | def sign(self, path: str, expiration: int = 3600, **kwargs): |
| 1371 | """Generate a presigned URL for S3 object access. |