Repository navigation
NDI Cloud file CRC-32: lookupFiles, checksummed uploads, crc32 in file listings - #1025
Merged
Merged
Conversation
…ds, crc32 in listings
Client side of Waltham-Data-Science/ndi-cloud-node#162.
- ndi.fun.file.crc32 / crc32ToBase64: a local file's CRC-32 as base64 of
the 4-byte big-endian value (the S3 / NDI Cloud encoding), read in
chunks via java.util.zip.CRC32.
- getFileUploadURL takes 'checksumCRC32'; ndi.cloud.uploadSingleFile
sends it by default ('checksum', true), so S3 rejects a corrupted
upload and the cloud records the file's crc32.
- ndi.cloud.api.files.lookupFiles(datasetId, uids): POST /files/lookup,
returning files (uid, uploaded, size, crc32) and missing uids; splits
lists over the server's 5000-uid limit.
- listFiles / listFilesAll rows carry crc32 ('' when none recorded).
- getSignedURLSet / getSignedURLSetAll return fileInfo (uid, uploaded,
size, crc32) for the page's files.
- Tests: FileCrc32OfflineTest (no network) and live tests in FilesTest
and SignedURLSetTest, which skip on an environment that predates the
server change.
Authored without a MATLAB runtime; needs MATLAB to run the tests.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SwsqFA9Zs1HGm6YM4g2XRV
Contributor
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1025 +/- ##
==========================================
+ Coverage 30.17% 30.32% +0.15%
==========================================
Files 870 876 +6
Lines 44076 44217 +141
==========================================
+ Hits 13298 13410 +112
- Misses 30778 30807 +29 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…162) On dev, a checksum carried in the upload URL's query string was neither validated nor stored by S3, so crc32 stayed empty and a mismatched upload was accepted. The server now signs x-amz-checksum-crc32 as a header (Waltham-Data-Science/ndi-cloud-node#163), so the PUT must send it. - putFiles / PutFiles take 'checksumCRC32' and send the header from both the curl and MATLAB HTTP paths. The value is checked to be a base64 CRC-32 before it goes into the curl command. - uploadSingleFile passes its checksum to putFiles. - FilesTest passes the checksum to putFiles; offline tests cover the header and the malformed-value refusal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SwsqFA9Zs1HGm6YM4g2XRV
A skip hid whether the tests ran at all; an environment without the lookup route or fileInfo now fails these tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SwsqFA9Zs1HGm6YM4g2XRV
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SwsqFA9Zs1HGm6YM4g2XRV
stevewds
approved these changes
Oct 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Client side of Waltham-Data-Science/ndi-cloud-node#162 (server PR: Waltham-Data-Science/ndi-cloud-node#163).
The goal is resumable direct-to-cloud imports. The cloud now records a CRC-32 for every uploaded file, so a client can tell whether the cloud copy matches a local file and re-upload only the files that don't.
Changes
ndi.fun.file.crc32(filePath)andndi.fun.file.crc32ToBase64(value)compute a local file's CRC-32 in the cloud's encoding: base64 of the 4-byte big-endian CRC-32 (IEEE), the same value S3 uses forx-amz-checksum-crc32. The file is read in chunks throughjava.util.zip.CRC32.ndi.cloud.api.files.getFileUploadURL(..., 'checksumCRC32', crc)signs the upload URL with the checksum, andputFiles(..., 'checksumCRC32', crc)sends the matchingx-amz-checksum-crc32header. S3 then rejects content that doesn't match, and the cloud records the value as the file'scrc32.ndi.cloud.uploadSingleFilenow does both by default ('checksum', true).ndi.cloud.api.files.lookupFiles(datasetId, uids)callsPOST /datasets/:id/files/lookup. It returnsfiles(uid, uploaded, size, crc32) andmissing(the uids the dataset has no record of), and signs no URLs. Lists longer than the server's 5000-uid limit are split into several calls.listFiles/listFilesAllrows now includecrc32(''when none was recorded). Before this change the client copied out a fixed set of fields, socrc32would have been dropped.getSignedURLSet/getSignedURLSetAllnow returnfileInfo, an Nx1 struct array (uid, uploaded, size, crc32) for the page's files. The server sends it as an array, not a uid-keyed object, sojsondecode's renaming of keys that start with a digit doesn't affect it.cloud.md) has a newlookupFilesrow and a "File checksums" section.Tests
tests/+ndi/+unittest/FileCrc32OfflineTest.mneeds no network. It covers:checksumCRC32in the upload URL, and thex-amz-checksum-crc32header inputFileslookupFilesrequest body (a single uid is still sent as a JSON array), the 5000-uid limit and an empty inputcrc32becomes'',missingbecomes a string row)signedURLSetPagehandling offileInfoFilesTest:crc32read back fromgetFileDetails,listFilesandlookupFiles, including a missing uiduploadSingleFilerecording the checksumSignedURLSetTest:fileInfomatches the URL map, andcrc32is set for files uploaded through the bulk path.SignedURLSetTest.testCreateAndWaitForSignedURLSetJoblikewise now fails, rather than skipping, when the signed-URL-set worker isn't configured (CONFIGURATION_ERROR / ENQUEUE_ERROR / JOB_CREATION_ERROR).🤖 Generated with Claude Code
https://claude.ai/code/session_01SwsqFA9Zs1HGm6YM4g2XRV
Generated by Claude Code