提交 3e64cf7a authored 作者: 张国庆's avatar 张国庆

fix;切割下载路径

上级 9375368b
import 'package:apk_update/apk_update.dart';
import 'package:apk_update/utils/toast_util.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
......@@ -52,6 +53,9 @@ class _MyAppState extends State<MyApp> {
"productCode": "carrier-driver-app",
},
onceDay: false,
downloadApkError: () {
ToastUtil.showToast('下载Apk错误');
},
paramsOSS: map,
appleId: "1585610919");
},
......
......@@ -89,8 +89,8 @@ class ApkUpdate {
"product-code": params["productCode"]
}))
.then((res) {
if (res.data == null || res.data['code'] != 0) {
debugPrint('获取OSS授权失败');
if (res.data == null || res.data is String) {
debugPrint('获取OSS授权失败: ${res.data}');
downloadApkError?.call();
return;
}
......@@ -100,6 +100,9 @@ class ApkUpdate {
var sk = map?["onceAccessKeySecret"];
var token = map?["onceSecurityToken"];
var objectKey = apkPath ?? "";
// apkPath https://mslapp-download.oss-cn-beijing.aliyuncs.com/msl-chengyun.apk 截取后:msl-chengyun.apk
objectKey = objectKey.substring(objectKey.lastIndexOf("/") + 1);
var endpoint = paramsOSS?["endpoint"];
var bucketName = paramsOSS?["bucketName"];
var localPath = path;
......@@ -110,6 +113,10 @@ class ApkUpdate {
}
ApkUpdatePlatform.instance.downloadApk(
ak, sk, token, objectKey, endpoint, bucketName, localPath);
}).catchError((e) {
debugPrint('获取OSS授权失败');
downloadApkError?.call();
return;
});
},
downloadApkError: () {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论