You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
3.5 KiB
Dart
97 lines
3.5 KiB
Dart
// import 'dart:convert';
|
|
// import 'dart:html' as html;
|
|
//
|
|
// import 'package:diplomaticquarterapp/pages/videocall-webrtc-rnd/utils/blob-extension.dart';
|
|
// import 'package:flutter/cupertino.dart';
|
|
// import 'package:http/http.dart' as http;
|
|
//
|
|
// // should run on port '65482' add to additional arguments --web-port=65482
|
|
// class UploadRecording{
|
|
//
|
|
// final url = "https://vcallapi.hmg.com/api/videocall/trackMeeting";
|
|
// // final url = "https://10.20.200.186/api/videocall/trackMeeting";
|
|
// upload(html.Blob blob, {@required Map<String, String> params, @required Function completion, @required Function(double) onProgress}) async{
|
|
//
|
|
// final bytes = await blob.readBytes();
|
|
// final filename = "${DateTime.now().millisecondsSinceEpoch}.webm";
|
|
// final file = http.MultipartFile.fromBytes('file', bytes ?? [], filename: filename);
|
|
//
|
|
// var request = http.MultipartRequest('POST', Uri.parse(url));
|
|
// request.files.add(file);
|
|
// request.fields.addAll({'fileName':filename,...params});
|
|
//
|
|
// print("Uploading video of '${blob.size}' bytes");
|
|
// var response = await request.send().catchError((e){
|
|
// print(e.toString());
|
|
// completion(e.toString());
|
|
// });
|
|
//
|
|
// print(response.statusCode);
|
|
// if (response.statusCode == 200) {
|
|
// final bytes = await response.stream.toBytes();
|
|
// final jsonString = utf8.decode(bytes);
|
|
// final json = jsonDecode(jsonString);
|
|
// if(json == null)
|
|
// completion('200: Invalid response format');
|
|
// else
|
|
// completion(json);
|
|
//
|
|
// }else {
|
|
// print(response.reasonPhrase);
|
|
// completion(response.reasonPhrase);
|
|
// }
|
|
// }
|
|
//
|
|
// _upload(html.Blob blob, {@required Map<String, String> params, @required Function completion, @required Function(double) onProgress}) async{
|
|
// final blobBytes = await blob.readBytes();
|
|
//
|
|
// Map<String, dynamic> body = {};
|
|
// body.addAll(params);
|
|
// body['file'] = blobBytes ?? [];
|
|
// body['fileName'] = "${DateTime.now().millisecondsSinceEpoch}.webm";
|
|
//
|
|
// final json = jsonEncode(body);
|
|
//
|
|
// var request = http.StreamedRequest('POST', Uri.parse(url));
|
|
//
|
|
// var totalLength = json.length;// Total length (to calculate upload progress)
|
|
// var transferredLength = 0;// Length transferred (to calculate upload progress)
|
|
// var uploadProgress = 0.0; // Upload progress (from 0.0 to 1.0)
|
|
//
|
|
// Stream.value(json).transform(utf8.encoder).listen((chunk) {
|
|
//
|
|
// transferredLength += chunk.length;
|
|
// uploadProgress = transferredLength / totalLength;
|
|
// // print("Chunk: ${chunk.length}, transferred: $transferredLength, progress: $uploadProgress");
|
|
// request.sink.add(chunk);
|
|
// onProgress(uploadProgress*100);
|
|
//
|
|
// }, onDone: () {
|
|
// print("Done. Total: $totalLength, transferred: $transferredLength, progress: $uploadProgress");
|
|
// request.sink.close();
|
|
// onProgress(uploadProgress*100);
|
|
// });
|
|
//
|
|
//
|
|
// print("Uploading video of '${blob.size}' bytes");
|
|
// var response = await request.send();
|
|
//
|
|
// print(response.statusCode);
|
|
// if (response.statusCode == 200){
|
|
//
|
|
// final bytes = await response.stream.toBytes();
|
|
// final jsonString = utf8.decode(bytes);
|
|
// final json = jsonDecode(jsonString);
|
|
// if(json == null)
|
|
// completion('200: Invalid response format');
|
|
// else
|
|
// completion(json);
|
|
//
|
|
//
|
|
// }else {
|
|
// print("${response.statusCode}: ${response.reasonPhrase}");
|
|
// completion(response.reasonPhrase);
|
|
// }
|
|
//
|
|
// }
|
|
// } |