From 30e82d1f5c0eb52bbb995173579065e53da60021 Mon Sep 17 00:00:00 2001 From: w-R <953969641@qq.com> Date: Wed, 12 Jan 2022 10:18:51 +0800 Subject: [PATCH] =?UTF-8?q?ios=E8=A7=86=E9=A2=91=E6=92=AD=E6=94=BE?= =?UTF-8?q?=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/community/release_dynamic.dart | 2 ++ lib/mine/user_info_page.dart | 2 +- lib/retrofit/retrofit_api.dart | 2 +- lib/retrofit/retrofit_api.g.dart | 6 ++++-- pubspec.lock | 2 +- pubspec.yaml | 2 +- 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/community/release_dynamic.dart b/lib/community/release_dynamic.dart index cacbb575..1ac329e9 100644 --- a/lib/community/release_dynamic.dart +++ b/lib/community/release_dynamic.dart @@ -196,6 +196,7 @@ class _ReleaseDynamic extends State { BaseData baseData = await apiService.upload( File(thumbnail), 123123123, + dynamicType == 2 ); if (baseData != null && baseData.isSuccess) { UploadResult uploadResult = baseData.data; @@ -207,6 +208,7 @@ class _ReleaseDynamic extends State { BaseData baseData = await apiService.upload( file, 123123123, + dynamicType == 2 ); if (baseData != null && baseData.isSuccess) { UploadResult uploadResult = baseData.data; diff --git a/lib/mine/user_info_page.dart b/lib/mine/user_info_page.dart index 72bd318d..e774a7aa 100644 --- a/lib/mine/user_info_page.dart +++ b/lib/mine/user_info_page.dart @@ -356,7 +356,7 @@ class _UserInfoPage extends State { ///文件上传 fileUpload() async { if (filePath != null && filePath != "" && await File(filePath).exists()) { - BaseData baseData = await apiService.upload(File(filePath), 123123123).catchError((onError) {}); + BaseData baseData = await apiService.upload(File(filePath), 123123123,false).catchError((onError) {}); if (baseData != null && baseData.isSuccess) { UploadResult uploadResult = baseData.data; modifyInfo["headimg"] = uploadResult.url; diff --git a/lib/retrofit/retrofit_api.dart b/lib/retrofit/retrofit_api.dart index cf056f6e..0d7deff9 100644 --- a/lib/retrofit/retrofit_api.dart +++ b/lib/retrofit/retrofit_api.dart @@ -164,7 +164,7 @@ abstract class ApiService { @POST("/file/upload") @MultiPart() Future> upload( - @Part(name: "file") File data, @Part(name: "folderId") int folderId); + @Part(name: "file") File data, @Part(name: "folderId") int folderId,bool isVideo); /// 周边搜索 @GET( diff --git a/lib/retrofit/retrofit_api.g.dart b/lib/retrofit/retrofit_api.g.dart index d221d3b7..8ead78b2 100644 --- a/lib/retrofit/retrofit_api.g.dart +++ b/lib/retrofit/retrofit_api.g.dart @@ -17,15 +17,17 @@ class _ApiService implements ApiService { String baseUrl; @override - Future> upload(data, folderId) async { + Future> upload(data, folderId,bool isVideo) async { ArgumentError.checkNotNull(data, 'data'); ArgumentError.checkNotNull(folderId, 'folderId'); const _extra = {}; final queryParameters = {}; final _data = FormData(); String fileName = data.path.split(Platform.pathSeparator).last; - if(!fileName.contains(".jpeg") && !fileName.contains(".mp4") && !fileName.contains(".png")) + if(!isVideo && !fileName.contains(".jpeg") && !fileName.contains(".png")) fileName += ".jpeg"; + else if(isVideo && !fileName.contains(".mp4")) + fileName += ".mp4"; _data.files.add(MapEntry( 'file', MultipartFile.fromFileSync(data.path, diff --git a/pubspec.lock b/pubspec.lock index f73d2d1e..81da05a4 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -746,7 +746,7 @@ packages: name: tpns_flutter_plugin url: "https://pub.flutter-io.cn" source: hosted - version: "1.1.0" + version: "1.0.8" transformer_page_view: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 135b2fa4..af2fb40b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -19,7 +19,7 @@ dependencies: keframe: ^2.0.2 #滑动组件卡顿优化 - tpns_flutter_plugin: + tpns_flutter_plugin: 1.0.8 # git: # url: git://github.com/TencentCloud/TPNS-Flutter-Plugin # ref: V1.1.2