Skip to content

Commit

Permalink
documents how to send additional fields of arbitrary type (#127)
Browse files Browse the repository at this point in the history
* documents how to send additional fields of arbitrary type
  • Loading branch information
Sebastian Roth authored Dec 22, 2020
1 parent b4ea8aa commit 9dd202a
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions example/integration_test/flutter_uploader_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,37 @@ void main() {
expect(res.status, UploadTaskStatus.complete);
});

testWidgets('can submit custom data', (tester) async {
var fileItem = FileItem(path: await _tmpFile(), field: 'file');

final taskId = await uploader.enqueue(
MultipartFormDataUpload(url: url.toString(), files: [
fileItem
], data: {
'simpleKey': 'simpleValue',
'listOf': jsonEncode(['data', 'data', 'data']),
'dictionaryOf': jsonEncode({
'key1': 'value1',
'key2': 'value2',
}),
}),
);

expect(taskId, isNotNull);

final res = await uploader.result.firstWhere(isCompleted(taskId));
final json = jsonDecode(res.response);
print(json);

expect(json['request']['fields']['simpleKey'], 'simpleValue');
expect(jsonDecode(json['request']['fields']['listOf']),
['data', 'data', 'data']);
expect(jsonDecode(json['request']['fields']['dictionaryOf']), {
'key1': 'value1',
'key2': 'value2',
});
});

testWidgets("can overwrite 'Accept' header", (WidgetTester tester) async {
var fileItem = FileItem(path: await _tmpFile(), field: 'file');

Expand Down

0 comments on commit 9dd202a

Please sign in to comment.