Three problems tangled together in this class.
The unit is wrong. The config field is called partSizeMB but it is compared against 5 * 1024 * 1024 and assigned straight to a byte count. UploadManager happens to pass bytes so it works, but BYOS3ApiProvider.uploadMultipartParallely forwards params.partSizeMB from the caller untouched. Anyone passing 10 meaning 10MB fails the >= 5242880 check and silently gets 5MB parts instead.
Resume can never work. The constructor calls localStorage.removeItem for this key, and saveState writes to that same key after every part. So a fresh uploader wipes the saved state before anything could read it. Nothing ever calls a restore path. The persistence is write-only.
It breaks outside the browser. That localStorage call sits in the constructor of a package whose tsconfig targets Node (module: NodeNext) and whose own test suite runs in environment: 'node'. Constructing a MultipartUploader server-side throws localStorage is not defined.
Where:
s3-api/src/utils/multipartUploader.ts (lines 33-38, 40-51, 150-184)
s3-api/src/core/types.ts (MultipartUploadParams, MultipartUploadConfig)
s3-api/src/index.ts (uploadMultipartParallely)
What to do:
- Pick one unit and name it honestly - either
partSizeBytes, or keep MB and multiply inside the constructor
- Guard
localStorage behind a typeof window !== 'undefined' check, or inject a storage adapter
- Either finish resume-across-reload (look up saved state by key on construction instead of deleting it) or delete
saveState entirely - right now it is pure overhead writing JSON to localStorage after every part
Three problems tangled together in this class.
The unit is wrong. The config field is called
partSizeMBbut it is compared against5 * 1024 * 1024and assigned straight to a byte count.UploadManagerhappens to pass bytes so it works, butBYOS3ApiProvider.uploadMultipartParallelyforwardsparams.partSizeMBfrom the caller untouched. Anyone passing10meaning 10MB fails the>= 5242880check and silently gets 5MB parts instead.Resume can never work. The constructor calls
localStorage.removeItemfor this key, andsaveStatewrites to that same key after every part. So a fresh uploader wipes the saved state before anything could read it. Nothing ever calls a restore path. The persistence is write-only.It breaks outside the browser. That
localStoragecall sits in the constructor of a package whose tsconfig targets Node (module: NodeNext) and whose own test suite runs inenvironment: 'node'. Constructing aMultipartUploaderserver-side throwslocalStorage is not defined.Where:
s3-api/src/utils/multipartUploader.ts(lines 33-38, 40-51, 150-184)s3-api/src/core/types.ts(MultipartUploadParams,MultipartUploadConfig)s3-api/src/index.ts(uploadMultipartParallely)What to do:
partSizeBytes, or keep MB and multiply inside the constructorlocalStoragebehind atypeof window !== 'undefined'check, or inject a storage adaptersaveStateentirely - right now it is pure overhead writing JSON to localStorage after every part