|
@@ -1,3 +1,4 @@
|
|
|
|
|
+import 'dart:convert';
|
|
|
import 'dart:io';
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
import 'package:dio/dio.dart';
|
|
import 'package:dio/dio.dart';
|
|
@@ -11,6 +12,7 @@ import 'package:flutter_foreground_task/flutter_foreground_task.dart';
|
|
|
import 'package:get/get.dart';
|
|
import 'package:get/get.dart';
|
|
|
import 'package:get/get_connect/http/src/request/request.dart';
|
|
import 'package:get/get_connect/http/src/request/request.dart';
|
|
|
import 'package:path_provider/path_provider.dart';
|
|
import 'package:path_provider/path_provider.dart';
|
|
|
|
|
+import '../../base/base_response.dart';
|
|
|
import '../../dialog/talk_share_dialog.dart';
|
|
import '../../dialog/talk_share_dialog.dart';
|
|
|
import '../../utils/foreground_util.dart';
|
|
import '../../utils/foreground_util.dart';
|
|
|
import '../../utils/http_handler.dart';
|
|
import '../../utils/http_handler.dart';
|
|
@@ -54,18 +56,34 @@ class TalkRepository {
|
|
|
String talkId, String fileName, ShareTalkType type) async {
|
|
String talkId, String fileName, ShareTalkType type) async {
|
|
|
ResponseBody responseBody = await atmobStreamApi.talkExportFile(
|
|
ResponseBody responseBody = await atmobStreamApi.talkExportFile(
|
|
|
TalkExportRequest(talkId, type == ShareTalkType.summary ? 1 : 2));
|
|
TalkExportRequest(talkId, type == ShareTalkType.summary ? 1 : 2));
|
|
|
|
|
+ List<String>? contentType = responseBody.headers['Content-Type'];
|
|
|
|
|
+
|
|
|
|
|
+ if (contentType != null) {
|
|
|
|
|
+ for (var value in contentType) {
|
|
|
|
|
+ if (value.contains('application/json')) {
|
|
|
|
|
+ BaseResponse<String> baseResponse = BaseResponse.fromJson(
|
|
|
|
|
+ jsonDecode(await responseBody.stream
|
|
|
|
|
+ .map((bytes) => utf8.decoder.convert(bytes))
|
|
|
|
|
+ .toList()
|
|
|
|
|
+ .then((value) => value.join())),
|
|
|
|
|
+ (json) => json as String);
|
|
|
|
|
+ throw ServerErrorException(baseResponse.code, baseResponse.message);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ final directory = await getTemporaryDirectory();
|
|
|
|
|
+ final filePath = '${directory.path}/export/$fileName';
|
|
|
|
|
+
|
|
|
|
|
+ final file = File(filePath);
|
|
|
|
|
+
|
|
|
|
|
+ if (!await file.exists()) {
|
|
|
|
|
+ await file.create(recursive: true);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- final directory = await getTemporaryDirectory();
|
|
|
|
|
- final filePath = '${directory.path}/export/$fileName';
|
|
|
|
|
-
|
|
|
|
|
- final file = File(filePath);
|
|
|
|
|
-
|
|
|
|
|
- if (!await file.exists()) {
|
|
|
|
|
- await file.create(recursive: true);
|
|
|
|
|
|
|
+ await file.writeAsBytes(await responseBody.stream.toBytes());
|
|
|
|
|
+ return file;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- await file.writeAsBytes(await responseBody.stream.toBytes());
|
|
|
|
|
- return file;
|
|
|
|
|
|
|
+ throw Exception('Invalid content type');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void setTalkList(List<TalkBean> list) {
|
|
void setTalkList(List<TalkBean> list) {
|