t×tecexpressby TeKOcloud
ENv0.7.1
API & Datentypen / FLUTTER

txHttpUpload.

Erzeugt einen Multipart-POST-Adapter. Der Server muss Chunks zusammensetzen. Nicht erfolgreiche HTTP-Antworten und Netzwerkfehler schlagen fehl.

Parameter: config mit erforderlicher URL; Rückgabe TxUploadAdapter. Der Adapter erhält file und context und liefert asynchron den letzten HTTP-Antworttext. fieldName = file; zusätzliche Felder/Header standardmäßig leer. chunkSize muss positiv sein; chunkFields erhält file, nullbasierten index und count. Abbruch und HTTP-/Netzwerkfehler lehnen die Operation ab. Kein automatisches JSON-Parsing und keine automatische serverseitige Chunk-Zusammenführung.

dart
TxUploadAdapter txHttpUpload(TxHttpUploadConfig config)
dart
import 'dart:typed_data';
import 'package:tecexpress/tecexpress.dart';

Future<void> example() async {
  // Requires your own multipart server with matching chunk assembly.
  final upload = txHttpUpload(TxHttpUploadConfig(url: Uri.parse('https://example.com/api/upload')));
  await upload(TxFile.fromData(Uint8List.fromList([72, 105]), name: 'hello.txt'), TxUploadContext(cancellation: TxCancellation(), onProgress: (loaded, total) => print('$loaded/$total')));
}