* Builds a metadata stub for an S3 object. The content hash combines the key * and ETag — S3's ETag changes whenever object content changes, making it an * ideal change indicator. Used by both listDocuments and getDocument to * guarantee identical hashes.
(ctx: S3Context, entry: S3ObjectEntry)
| 434 | * guarantee identical hashes. |
| 435 | */ |
| 436 | function objectToStub(ctx: S3Context, entry: S3ObjectEntry): ExternalDocument { |
| 437 | const title = entry.key.split('/').pop() || entry.key |
| 438 | const prefix = entry.key.includes('/') ? entry.key.slice(0, entry.key.lastIndexOf('/')) : '' |
| 439 | |
| 440 | return { |
| 441 | externalId: entry.key, |
| 442 | title, |
| 443 | content: '', |
| 444 | contentDeferred: true, |
| 445 | mimeType: 'text/plain', |
| 446 | sourceUrl: buildUrl(ctx, buildObjectPath(ctx, entry.key), ''), |
| 447 | contentHash: `s3:${entry.key}:${entry.etag}`, |
| 448 | metadata: { |
| 449 | key: entry.key, |
| 450 | prefix, |
| 451 | etag: entry.etag, |
| 452 | lastModified: entry.lastModified, |
| 453 | fileSize: entry.size, |
| 454 | }, |
| 455 | } |
| 456 | } |
| 457 | |
| 458 | /** |
| 459 | * Performs a single ListObjectsV2 page request and returns the parsed result. |
no test coverage detected