InMemoryUploadAdapter class
A fake backend that keeps uploads in memory.
Intended for tests, demos and the example app — it lets you exercise the whole pipeline (chunking, progress, pause, resume, retry, queueing) without a server. Do not use it in production: everything it "stores" is discarded when the process exits.
final SmartUploader uploader = SmartUploader(
adapter: InMemoryUploadAdapter(latency: const Duration(milliseconds: 50)),
);
- Inheritance
-
- Object
- UploadAdapter
- InMemoryUploadAdapter
Constructors
- InMemoryUploadAdapter({Duration latency = Duration.zero, bool retainBytes = false, String baseUrl = 'memory://uploads'})
- Creates a fake backend.
Properties
- baseUrl → String
-
Prefix of the URL reported on completion.
final
-
completedUploads
→ Iterable<
String> -
Ids of uploads that were finalised.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- latency → Duration
-
Artificial delay applied to every call, to make progress visible in a
demo UI.
final
- retainBytes → bool
-
Whether to keep chunk payloads, so tests can assert on the reassembled
file.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
bytesOf(
String uploadId) → Uint8List? -
The reassembled bytes of
uploadId, when retainBytes is on. -
bytesReceived(
String uploadId) → int -
How many bytes were accepted for
uploadId. -
cancel(
UploadSession session) → Future< void> -
Aborts the upload and releases server-side resources.
override
-
complete(
UploadSession session) → Future< UploadResult> -
Finalises the upload after every chunk has been acknowledged.
override
-
initialize(
UploadRequest request) → Future< UploadSession> -
Opens a server-side session for
request.override -
isRetryable(
Object error) → bool -
Classifies an
errorthe adapter itself threw.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reset(
) → void - Forgets everything.
-
restore(
UploadSession session) → Future< UploadSession> -
Revalidates a persisted
sessionbefore an upload is resumed.inherited -
toString(
) → String -
A string representation of this object.
inherited
-
uploadChunk(
UploadSession session, UploadChunk chunk) → Future< ChunkUploadResult> -
Sends one
chunk.override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited