The other request goes through fine, but when I reach this bit of code it throws an error.
FormData formData = new FormData.from({
"fileData": new UploadFileInfo(
_uploadFile, basename(_uploadFile.path))
});
void uploadVideo(BuildContext context, File _uploadFile) async {
final _name = "Test Video Here";
final _description = "This is a test description";
if (_controller == null) {
globals.Utility
.showAlertPopup(context, "Info", "Video Required for Upload!");
} else {
final _ks = await globals.Utility.getKalturaSession();
String _token = "";
// Add Video
await http
.get(
'https://www.kaltura.com/api_v3/service/uploadtoken/action/add?ks=$_ks&format=1')
.then((response) {
Map<String, dynamic> _json = json.decode(response.body);
_token = _json['id'].toString();
print('"Token: $_token');
});
// Upload Video
String _url =
"https://www.kaltura.com/api_v3/service/uploadtoken/action/upload?ks=$_ks&format=1&uploadTokenId=$_token&resume=false&finalChunk=true&resumeAt=-1";
print("Path: " + _uploadFile.uri.toString());
Dio dio = new Dio();
Response response;
FormData formData = new FormData.from({
"fileData": new UploadFileInfo(
_uploadFile, basename(_uploadFile.path))
});
response = await dio.post(_url, data: formData);
print("RESPONSE: " + response.data.toString());
// Update Video Info (Name, Desctiption, Tags)
var _formName = Uri.encodeQueryComponent(r'mediaEntry[name]');
var _formDesription =
Uri.encodeQueryComponent(r'mediaEntry[description]');
var _formTags = Uri.encodeQueryComponent(r'mediaEntry[tags]');
var _formType = Uri.encodeQueryComponent(r'mediaEntry[mediaType]');
await http
.get(
'https://www.kaltura.com/api_v3/service/media/action/addFromUploadedFile?ks=$_ks&format=1&$_formTags=${globals.userCompanyID}&$_formName=$_name&$_formDesription=$_description&uploadTokenId=$_token&$_formType=1')
.then((response) {
print('Updated Info...');
Map<String, dynamic> _json = json.decode(response.body);
// Verify Upload
globals.videoID = "" + _json["id"].toString();
if (globals.videoID.length > 1) {
globals.Utility
.showAlertPopup(context, "Info",
"The video you just uploaded will be avalible in 'Videos' when it finishes processing.")
.then((onValue) {
Navigator.pop(context);
});
} else {
globals.Utility
.showAlertPopup(context, "Info",
"There was an error uploading the video, please try again later.")
.then((onValue) {
Navigator.pop(context);
});
}
});
}
}
E/flutter ( 2547): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
E/flutter ( 2547): type '_InternalLinkedHashMap<dynamic, dynamic>' is not a subtype of type 'Map<String, dynamic>' where
E/flutter ( 2547): _InternalLinkedHashMap is from dart:collection
E/flutter ( 2547): Map is from dart:core
E/flutter ( 2547): String is from dart:core
E/flutter ( 2547):
E/flutter ( 2547): #0 new FormData.from (package:dio/src/FormData.dart:29:12)
E/flutter ( 2547): #1 _CameraPageState.uploadVideo (package:Unify_Mobile/camera.dart:167:31)
E/flutter ( 2547): <asynchronous suspension>
E/flutter ( 2547): #2 _CameraPageState.build.<anonymous closure> (package:Unify_Mobile/camera.dart:222:17)
E/flutter ( 2547): #3 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:494:14)
E/flutter ( 2547): #4 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:549:30)
E/flutter ( 2547): #5 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
E/flutter ( 2547): #6 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:161:9)
E/flutter ( 2547): #7 TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:94:7)
E/flutter ( 2547): #8 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:315:9)
E/flutter ( 2547): #9 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:73:12)
E/flutter ( 2547): #10 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101:11)
E/flutter ( 2547): #11 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:143:19)
E/flutter ( 2547): #12 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:121:22)
E/flutter ( 2547): #13 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:101:7)
E/flutter ( 2547): #14 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:64:7)
E/flutter ( 2547): #15 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:48:7)
E/flutter ( 2547): #16 _invoke1 (dart:ui/hooks.dart:134:13)
E/flutter ( 2547): #17 _dispatchPointerDataPacket (dart:ui/hooks.dart:91:5)
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v0.3.2, on Mac OS X 10.13.4 17E199, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 9.3)
[✓] Android Studio (version 3.1)
[✓] VS Code (version 1.23.1)
[✓] Connected devices (3 available)
• No issues found!