[2.0.0]
A full rewrite of the upload engine for spec-compliant, production-grade GCS resumable uploads.
Breaking: the public API has changed — see the migration table in the README.
Added
- New public API under
io.fastpix.uploads:FastPixUploader(replacesFastPixUploadSdk) with a fluentBuilderandstart()/pause()/resume()/cancel()methods.UploadListener(replacesFastPixUploadCallbacks) with no-op defaults — override only what you need. New callbacks:onStateChange(UploadState),onPrepared(...),onChunkUploaded(...),onRetryScheduled(...),onCancelled(...).UploadStateenum (IDLE,PREPARING,UPLOADING,PAUSED,RETRYING,NETWORK_LOST,QUERYING_STATUS,COMPLETED,FAILED,CANCELLED) for explicit lifecycle modelling.UploadErrorsealed class with typed variants:InvalidConfiguration,FileNotFound,FileNotReadable,FileEmpty,FileReadFailure,NetworkFailure,SessionExpired(HTTP 410),ClientError(code),ServerError(code),RetryLimitExceeded,UnexpectedResponse.
- GCS spec compliance:
- Chunk PUTs with
Content-Range: bytes start-end/total; non-final chunk size enforced as a multiple of 256 KiB at build time. - Server-authoritative resume: parses the
Rangeheader from308 Resume Incompleteand resumes fromlast + 1. Handles 308 without aRangeheader (resume from byte 0) per spec. - Always issues a status query (
PUTwithContent-Range: bytes */TOTAL, empty body) before resuming after pause, network loss, or transient failure — never assumes how much the server has. - HTTP 410 →
UploadError.SessionExpired. Retryable: 408, 429, 5xx. Fatal: other 4xx.
- Chunk PUTs with
- Smooth, monotonic progress. Updates fire as each chunk streams (no longer only at chunk boundaries), throttled to one event per integer-percent change. A CAS-guarded high-water mark ensures progress never regresses on retry.
- Explicit upload state machine with validated transitions. Structurally impossible to send a chunk PUT after pause/retry/network-loss without first going through
QUERYING_STATUS. - Single-threaded engine. All state mutations serialised on one executor; OkHttp callbacks, network events, consumer commands, and retry timers all funnel through it. No race conditions.
- Multi-transport network awareness. Tracks the active set of networks with INTERNET capability; only signals offline when all transports drop. Transient WiFi/cellular handover events no longer trip false
NETWORK_LOST. - Configurable retry policy. Full-jitter exponential backoff (
retryBaseDelay,retryMaxDelay), bounded bymaxRetries. - Main-thread callback dispatch by default. Listener calls land on the main looper; consumers no longer need
runOnUiThreadwrappers. Override viaBuilder.callbackExecutor(Executor). - Optional HTTP logging via
Builder.debugLogging(true). Off by default — release builds no longer leak signed session URIs to logcat. - JUnit unit tests for
GcsResumableProtocol,UploadStateMachine,RetryPolicy, andCallbackDispatcher(47 tests total).
Fixed
- Retries no longer silently disabled after the first successful chunk. The retry executor is now permanent for the upload's lifetime; previously a
CoroutineScope.cancel()killed it after chunk 1, causing later failures to hang forever. - Network failures are now routed through the retry path. Previously any
IOException(broken pipe, DNS hiccup, TLS reset, OkHttp cancel) terminated the upload withonError. Now classified, backed off, and resumed via status query. onSuccess,onFailure, andonCancellednow actually fire. A "defense in depth" terminated-flag silently dropped the terminal callback itself. Removed.cancel()no longer double-firesonError+onCancelled. OkHttp call cancellation is now correctly distinguished from real failures via a generation counter.pause()no longer leaks asonError. Intentional cancellations are detected inonFailureand suppressed.NetworkCallbackno longer leaks across uploads. Per-uploader registration with explicitunregisterNetworkCallbackon terminal.- Working Wi-Fi no longer falsely reported as
NETWORK_LOST. Dropped theNET_CAPABILITY_VALIDATEDrequirement, which is gated on a probe to Google'sconnectivitycheckendpoint and is missing for the first few seconds of a fresh connection (and indefinitely on networks where that endpoint is blocked, e.g. corporate Wi-Fi). - Transient losses during WiFi/cellular handover no longer trigger
NETWORK_LOST. Network state is now derived from the set of matching networks; offline is signalled only when all transports drop. - File reads no longer silently misalign on large files.
RandomAccessFile.seek()replacesInputStream.skip(), which was allowed to skip fewer bytes than requested. - OkHttp no longer silently re-PUTs bodies on connection failure.
retryOnConnectionFailure(false)lets the upload engine own all retry semantics. - Public commands after terminal state no longer crash.
cancel()called twice, late OkHttp callbacks, and late connectivity events post-teardown now silently no-op instead of throwingRejectedExecutionException.
Changed
- Minimum SDK bumped from API 21 to API 24.
- Default chunk size changed from 16 MiB to 8 MiB (the GCS-recommended value).
- Method renames (see migration table in README):
setSignedUrl→sessionUri,setFile→file,setChunkSize→chunkSize,setMaxRetries→maxRetries,setRetryDelay→retryBaseDelay+retryMaxDelay,callback→listener,startUpload→start,pauseUploading→pause,resumeUploading→resume,abort→cancel. - Errors:
UploadExceptionsand its subclasses replaced with theUploadErrorsealed hierarchy.
Removed
FastPixUploadSdk,FastPixUploadCallbacks,UploadExceptions,StreamingFileRequestBody,RetryHelper,NetworkHandler,UploadEventType.