getExistingUploadFileRequest static method
Returns the existing upload batch for a destination, re-attached to its
persisted state, or null when none exists (offline-uploads-spec OU-13).
This is the restore/read-back path, separate from create: call it on chat open to rebuild a composer's attachment tray after a connection drop or an app restart. Each file comes back with its current state โ uploaded files as done, everything else as retryable-failed (spec ยง8) โ and every parameter identical to when the batch was created (OU-13a). Uploads are never auto-resumed (OU-6); the user drives retry.
The batch is keyed by the triple (receiverType, receiverId, parentMessageId); pass parentMessageId to restore a thread composer's
batch. Returns null when offline is disabled โ offline-off is
byte-identical to today.
Implementation
static Future<UploadFileRequest?> getExistingUploadFileRequest(
String receiverId,
String receiverType, {
int? parentMessageId,
}) async {
final sdk = SdkRegistry.getInstance();
final repo = sdk.uploads;
final durability = repo.durability;
if (durability == null || !durability.available) return null;
final snapshot = await durability.loadBatchByTriple(
receiverType,
receiverId,
parentMessageId,
);
if (snapshot == null) return null;
final batchId = repo.hydrateBatch(snapshot);
return UploadFileRequest.restored(
repo,
receiverId,
receiverType,
batchId: batchId,
parentMessageId: snapshot.parentMessageId,
concurrency: snapshot.concurrency,
);
}