jlcool / aliossflutter Goto Github PK
View Code? Open in Web Editor NEW阿里云oss flutter
License: Apache License 2.0
阿里云oss flutter
License: Apache License 2.0
作者大大,我看你代码里面的版本是0.0.5,但是pub里面的版本还是0.0.4,是不是没发布?
W/System.err(24659): org.json.JSONException: No value for Data
W/System.err(24659): at org.json.JSONObject.get(JSONObject.java:392)
W/System.err(24659): at org.json.JSONObject.getString(JSONObject.java:553)
W/System.err(24659): at com.jlcool.aliossflutter.AliossflutterPlugin$1.getFederationToken(AliossflutterPlugin.java:110)
W/System.err(24659): at com.alibaba.sdk.android.oss.common.auth.OSSFederationCredentialProvider.getValidFederationToken(OSSFederationCredentialProvider.java:30)
W/System.err(24659): at com.alibaba.sdk.android.oss.common.utils.OSSUtils.signRequest(OSSUtils.java:664)
W/System.err(24659): at com.alibaba.sdk.android.oss.network.OSSRequestTask.call(OSSRequestTask.java:86)
W/System.err(24659): at com.alibaba.sdk.android.oss.network.OSSRequestTask.call(OSSRequestTask.java:243)
W/System.err(24659): at com.alibaba.sdk.android.oss.network.OSSRequestTask.call(OSSRequestTask.java:243)
W/System.err(24659): at com.alibaba.sdk.android.oss.network.OSSRequestTask.call(OSSRequestTask.java:44)
W/System.err(24659): at java.util.concurrent.FutureTask.run(FutureTask.java:266)
W/System.err(24659): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/System.err(24659): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/System.err(24659): at java.lang.Thread.run(Thread.java:764)
W/System.err(24659): com.alibaba.sdk.android.oss.ClientException: Can't get a federation token
W/System.err(24659): [ErrorMessage]: Can't get a federation token
W/System.err(24659): at com.alibaba.sdk.android.oss.network.OSSRequestTask.call(OSSRequestTask.java:200)
W/System.err(24659): at com.alibaba.sdk.android.oss.network.OSSRequestTask.call(OSSRequestTask.java:243)
W/System.err(24659): at com.alibaba.sdk.android.oss.network.OSSRequestTask.call(OSSRequestTask.java:243)
W/System.err(24659): at com.alibaba.sdk.android.oss.network.OSSRequestTask.call(OSSRequestTask.java:44)
W/System.err(24659): at java.util.concurrent.FutureTask.run(FutureTask.java:266)
W/System.err(24659): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/System.err(24659): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/System.err(24659): at java.lang.Thread.run(Thread.java:764)
W/System.err(24659): Caused by: java.io.IOException: Can't get a federation token
W/System.err(24659): at com.alibaba.sdk.android.oss.common.utils.OSSUtils.signRequest(OSSUtils.java:667)
W/System.err(24659): at com.alibaba.sdk.android.oss.network.OSSRequestTask.call(OSSRequestTask.java:86)
W/System.err(24659): ... 7 more
W/System.err(26694): java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread. Current thread: oss-android-api-thread
W/System.err(26694): at io.flutter.embedding.engine.FlutterJNI.ensureRunningOnMainThread(FlutterJNI.java:794)
W/System.err(26694): at io.flutter.embedding.engine.FlutterJNI.dispatchPlatformMessage(FlutterJNI.java:684)
W/System.err(26694): at io.flutter.embedding.engine.dart.DartMessenger.send(DartMessenger.java:80)
W/System.err(26694): at io.flutter.embedding.engine.dart.DartExecutor.send(DartExecutor.java:189)
W/System.err(26694): at io.flutter.view.FlutterNativeView.send(FlutterNativeView.java:155)
W/System.err(26694): at io.flutter.plugin.common.MethodChannel.invokeMethod(MethodChannel.java:98)
W/System.err(26694): at io.flutter.plugin.common.MethodChannel.invokeMethod(MethodChannel.java:84)
W/System.err(26694): at com.jlcool.aliossflutter.AliossflutterPlugin$3.onProgress(AliossflutterPlugin.java:229)
W/System.err(26694): at com.jlcool.aliossflutter.AliossflutterPlugin$3.onProgress(AliossflutterPlugin.java:220)
W/System.err(26694): at com.alibaba.sdk.android.oss.network.ProgressTouchableRequestBody.writeTo(ProgressTouchableRequestBody.java:65)
W/System.err(26694): at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:72)
W/System.err(26694): at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
W/System.err(26694): at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
W/System.err(26694): at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
W/System.err(26694): at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
W/System.err(26694): at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
W/System.err(26694): at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
W/System.err(26694): at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
W/System.err(26694): at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
W/System.err(26694): at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
W/System.err(26694): at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:126)
W/System.err(26694): at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
W/System.err(26694): at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
W/System.err(26694): at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200)
W/System.err(26694): at okhttp3.RealCall.execute(RealCall.java:77)
W/System.err(26694): at com.alibaba.sdk.android.oss.network.OSSRequestTask.call(OSSRequestTask.java:177)
W/System.err(26694): at com.alibaba.sdk.android.oss.network.OSSRequestTask.call(OSSRequestTask.java:44)
W/System.err(26694): at java.util.concurrent.FutureTask.run(FutureTask.java:266)
W/System.err(26694): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
W/System.err(26694): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
W/System.err(26694): at java.lang.Thread.run(Thread.java:764)
Xcode's output:
↳
In file included from /Users/cyc/.pub-cache/git/aliossflutter-615a996377e9769bbae4ccd7d0980e5ffe5e55d4/ios/Classes/AliossflutterPlugin.m:1:
/Users/cyc/.pub-cache/git/aliossflutter-615a996377e9769bbae4ccd7d0980e5ffe5e55d4/ios/Classes/AliossflutterPlugin.h:2:9: fatal error: 'AliyunOSSiOS/OSSService.h' file not found
#import <AliyunOSSiOS/OSSService.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
responseFromUpload.listen 如何取消监听
FAILURE: Build failed with an exception.
Could not determine artifacts for com.aliyun.dpa:oss-android-sdk:2.9.2
Could not get resource 'https://jcenter.bintray.com/com/aliyun/dpa/oss-android-sdk/2.9.2/oss-android-sdk-2.9.2.aar'.
> Could not HEAD 'https://jcenter.bintray.com/com/aliyun/dpa/oss-android-sdk/2.9.2/oss-android-sdk-2.9.2.aar'.
> Connect to d29vzk4ow07wi7.cloudfront.net:443 [d29vzk4ow07wi7.cloudfront.net/54.192.84.168, d29vzk4ow07wi7.cloudfront.net/54.192.84.173, d29vzk4ow07wi7.cloudfront.net/54.192.84.128, d29vzk4ow07wi7.cloudfront.net/54.192.84.6] failed: Read timed out
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
作者你好,我把aliossflutter集成后,上传图片都是ok的,但是返回值 servercallback 一直是null
因为我们oss的服务端接口在已有的Android app上工作都是ok的,所有我确认我们servercallback 会返回一个Json串,但是使用aliossflutter后,我理解应该在data.servercallback 拿到一个字符串(json串),但是现在是个null, 不知应该从哪里查起?
`
alioss.responseFromUpload.listen((data) {
print("data.success:${data.success}");
print("data.key:${data.key}");
print("data.msg:${data.msg}");
print("data.servercallback:${data.servercallback}");
}
`
----------下面是打印结果-----------
flutter: data.success:true
flutter: data.key:2020/05/12/898cadda544e668da67d60a4b6188c23.JPG
flutter: data.msg:null
flutter: data.servercallback:null
1.安卓init方法在主线程请求网络
2.iOS调用init方法的时候,没有调用错误回调(安卓端还没看)
我fork出去自己先改着用了,作者看到了有时间可以修改一下
com.alibaba.sdk.android.oss.ClientException: Compute signature failed!
Access Key Id you provided does not exist in our records 用secretInit 初始化上传 包这错
android.os.NetworkOnMainThreadException
W/System.err(13460): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1448)
W/System.err(13460): at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:102)
W/System.err(13460): at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:90)
W/System.err(13460): at java.net.InetAddress.getByName(InetAddress.java:743)
W/System.err(13460): at com.alibaba.sdk.android.oss.common.utils.OSSUtils.isValidateIP(OSSUtils.java:781)
W/System.err(13460): at com.alibaba.sdk.android.oss.OSSImpl.<init>(OSSImpl.java:117)
W/System.err(13460): at com.alibaba.sdk.android.oss.OSSClient.<init>(OSSClient.java:100)
W/System.err(13460): at com.alibaba.sdk.android.oss.OSSClient.<init>(OSSClient.java:88)
W/System.err(13460): at com.jlcool.aliossflutter.AliossflutterPlugin.secretInit(AliossflutterPlugin.java:139)
W/System.err(13460): at com.jlcool.aliossflutter.AliossflutterPlugin.onMethodCall(AliossflutterPlugin.java:103)
W/System.err(13460): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:222)
W/System.err(13460): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:96)
W/System.err(13460): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:643)
W/System.err(13460): at android.os.MessageQueue.nativePollOnce(Native Method)
W/System.err(13460): at android.os.MessageQueue.next(MessageQueue.java:325)
W/System.err(13460): at android.os.Looper.loop(Looper.java:142)
W/System.err(13460): at android.app.ActivityThread.main(ActivityThread.java:6938)
W/System.err(13460): at java.lang.reflect.Method.invoke(Native Method)
W/System.err(13460): at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
W/System.err(13460): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
private void secretInit() {
endpoint = _call.argument("endpoint");
final String accessKeyId = _call.argument("accessKeyId");
final String accessKeySecret = _call.argument("accessKeySecret");
final String _id = _call.argument("id");
final String securityToken = _call.argument("securityToken");
final Map<String, String> m1 = new HashMap();
m1.put("result", "success");
m1.put("id", _id);
final OSSCredentialProvider credentialProvider = new OSSStsTokenCredentialProvider(accessKeyId, accessKeySecret, securityToken);
oss = new OSSClient(registrar.context(), endpoint, credentialProvider);
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
channel.invokeMethod("onInit", m1);
}
});
}
提示冲突
sometimes, we want compress and then upload , so can we support the way of upload image data.
在应用刚打开的时候,调用初始化
String stsPath = UrlPath.baseUrl + UrlPath.stsToken;
AliOSSFlutter alioss = AliOSSFlutter();
alioss.init(stsPath, "http://oss-cn-hangzhou.aliyuncs.com");
//监听初始化
alioss.responseFromInit.listen((data){
if(data) {
logger.i("阿里云oss初始化成功");
}else{
logger.i("阿里云oss初始化失败");
}
});
stsPath是后台提供的一个api接口地址,
接口返回值是:
{
"StatusCode":200,
"AccessKeyId":"STS.NUYs1PG9rDboZ2t2ixzNp2v6n",
"AccessKeySecret":"7sZVNpUKeoVKsSLqc3KNpjSJnK2JYUGRfUkH318vYPvq",
"Expiration":"2020-06-16T04:49:13Z",
"SecurityToken":"CAISlQJ1q6Ft5B2yfSjIr5bsOIvkquZT86CEWBTF1mktdsFc3bOdjDz2IHpJfXloAOAWtf4+mWhW7vwflqJ4T55IQ1Dza8J148yNdb0SoMyT1fau5Jko1beXewHKeSOZsebWZ+LmNqS/Ht6md1HDkAJq3LL+bk/Mdle5MJqP+/EFA9MMRVv6F3kkYu1bPQx/ssQXGGLMPPK2SH7Qj3HXEVBjt3gb6wZ24r/txdaHuFiMzg+46JdM+9uoeML6P5c9YMwmD43t5oEsKPqdihw3wgNR6aJ7gJZD/Tr6pdyHCzFTmU7cbrOEqoQ/fFQjN/ViRfYe8eKPnPl5q/HVkJ/s1xFOMOdaXiLSXom8x9HeH+ekJkKpo0k4kdKnGoABsC0SQVCTHsxSX94BfTgkz59fRKZbur81anIU9AdqwW+/5ZOpaXgwlmIFMgtOg/DVb2O+ThRQFLag5aGImGX8AhrE7GIpaPeaTvzPbE8S0f5yG/0j5YJToZd4Sne3cY2otPPocru40iOXqj1Yf5j8JPewISZ/+ReqY0nm7t+Ykfw="
}
执行后打印了下面的日志
I/flutter (23991): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (23991): │ #0 Global.init.<anonymous closure> (package:qzone_app/common/Global.dart:138:18)
I/flutter (23991): │ #1 _rootRunUnary (dart:async/zone.dart:1192:38)
I/flutter (23991): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (23991): │ 💡 阿里云oss初始化成功
I/flutter (23991): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (23991): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (23991): │ #0 Global.init.<anonymous closure> (package:qzone_app/common/Global.dart:138:18)
I/flutter (23991): │ #1 _rootRunUnary (dart:async/zone.dart:1192:38)
I/flutter (23991): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (23991): │ 💡 阿里云oss初始化成功
I/flutter (23991): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
从日志上面看,初始化已成功:
然后选择图片上传,我封装了下面方法:
///oss上传文件
///使用:aliossflutter上传
///现在存在的bug: https://github.com/jlcool/aliossflutter/issues/27
/// context flutter的上下文
/// uid 上传文件所属的uid(一般是登录用户uid)
/// bucket 上传到oss 的bucket name
/// type 上传文件的业务类型
/// key 上传后文件的路径及文件名(即:oss 里面的key)
/// file 准备上传的文件
static Future<OssCallBackData> ossUploadFile2(BuildContext context, int uid, String bucket, String type, String key, File file) {
String path = file.path;
String key = OssHelper.buildOssKey(path, uid);
AliOSSFlutter alioss = AliOSSFlutter();
Map<String, dynamic> ossConfig = getOssConfig(key, type, uid);
logger.i("上传回调参数:$ossConfig");
//url签名:
//type=1 签名私有资源
//type=0 签名公开的访问URL
alioss.signUrl(bucket, key);
//监听url签名
alioss.responseFromSign.listen((data){
if(data.success) {
logger.i("url 签名 :${data.url}");
}else{
logger.i("url 签名失败");
}
});
//上传
//callbackHost
//发起回调请求时 Host 头的值,只有在设置了 callbackUrl 时才有效。
//如果没有配置 callbckHost,则会解析 callbackUrl 中的 url 并将解析出的 host 填充到 callbackHost 中。
//参考文档:https://help.aliyun.com/document_detail/31989.html?spm=a2c4g.11186623.2.30.6c474c07zQ8Q3w
alioss.upload(bucket, file.path, key,
callbackUrl: ossConfig['callbackUrl'],
callbackBodyType: ossConfig['callbackBodyType'],
callbackBody: ossConfig['callbackBody'],
callbackVars: ossConfig['callbackVars']);
//监听上传
alioss.responseFromUpload.listen((data) {
logger.i("data.success:${data.success}");
logger.i("data.key:${data.key}");
logger.i("data.msg:${data.msg}");
logger.i("data.servercallback:${data.servercallback}");
if(data.success) {
logger.i("上传成功 key: ${data.key} 服务器回调返回值:${data.servercallback}");
}else{
logger.i("上传失败");
}
});
alioss.responseFromProgress.listen((data){
if(data.key==key) {
logger.i("上传进度:${data.getProgress()} ");
}
});
}
执行后,一直在报错,相关的日志如下:
I/flutter (23991): 相册选择图片 开始执行
I/flutter (23991): 图片实际地址:/storage/emulated/0/sina/weibo/storage/video_download/cover/103778_1034:4505587493568548.jpg
I/flutter (23991): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (23991): │ #0 _UserIndexPageState._uploadFile (package:qzone_app/pages/user/UserIndexPage.dart:476:12)
I/flutter (23991): │ #1 _UserIndexPageState._getActionSheetList.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:qzone_app/pages/user/UserIndexPage.dart:352:23)
I/flutter (23991): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (23991): │ 💡 _uploadFile 开始执行
I/flutter (23991): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (23991): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (23991): │ #0 OssHelper.ossUploadFile2 (package:qzone_app/helper/OssHelper.dart:74:14)
I/flutter (23991): │ #1 _UserIndexPageState._uploadFile (package:qzone_app/pages/user/UserIndexPage.dart:483:17)
I/flutter (23991): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (23991): │ 💡 上传回调参数:{callbackUrl: https://api4.qqhot.com/osscallback/index, callbackBody: {"bucket":${bucket},"object":${object},"etag":${etag},"size":${size},"mimeType":${mimeType},"height":${imageInfo.height},"width":${imageInfo.width},"format":${imageInfo.format},"type":${x:type},"uid":${x:uid}}, callbackBodyType: application/json, callbackVars: {"x:type":"user_mobile_wallpaper", "x:uid":"2262561"}}
I/flutter (23991): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
E/flutter (23991): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: NoSuchMethodError: The method 'then' was called on null.
E/flutter (23991): Receiver: null
E/flutter (23991): Tried calling: then<Null>(Closure: (OssCallBackData) => Null)
E/flutter (23991): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
E/flutter (23991): #1 _UserIndexPageState._uploadFile (package:qzone_app/pages/user/UserIndexPage.dart:483:95)
E/flutter (23991): #2 _UserIndexPageState._getActionSheetList.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:qzone_app/pages/user/UserIndexPage.dart:352:23)
E/flutter (23991): #3 State.setState (package:flutter/src/widgets/framework.dart:1233:30)
E/flutter (23991): #4 _UserIndexPageState._getActionSheetList.<anonymous closure>.<anonymous closure> (package:qzone_app/pages/user/UserIndexPage.dart:347:21)
E/flutter (23991): #5 _rootRunUnary (dart:async/zone.dart:1192:38)
E/flutter (23991): #6 _CustomZone.runUnary (dart:async/zone.dart:1085:19)
E/flutter (23991): #7 _FutureListener.handleValue (dart:async/future_impl.dart:141:18)
E/flutter (23991): #8 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:682:45)
E/flutter (23991): #9 Future._propagateToListeners (dart:async/future_impl.dart:711:32)
E/flutter (23991): #10 Future._completeWithValue (dart:async/future_impl.dart:526:5)
E/flutter (23991): #11 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:36:15)
E/flutter (23991): #12 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:298:13)
E/flutter (23991): #13 PhotoManager._getFileWithId (package:photo_manager/src/manager.dart)
E/flutter (23991): #14 _rootRunUnary (dart:async/zone.dart:1192:38)
E/flutter (23991): #15 _CustomZone.runUnary (dart:async/zone.dart:1085:19)
E/flutter (23991): #16 _FutureListener.handleValue (dart:async/future_impl.dart:141:18)
E/flutter (23991): #17 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:682:45)
E/flutter (23991): #18 Future._propagateToListeners (dart:async/future_impl.dart:711:32)
E/flutter (23991): #19 Future._completeWithValue (dart:async/future_impl.dart:526:5)
E/flutter (23991): #20 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:36:15)
E/flutter (23991): #21 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:298:13)
E/flutter (23991): #22 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart)
E/flutter (23991): #23 _rootRunUnary (dart:async/zone.dart:1192:38)
E/flutter (23991): #24 _CustomZone.runUnary (dart:async/zone.dart:1085:19)
E/flutter (23991): #25 _FutureListener.handleValue (dart:async/future_impl.dart:141:18)
E/flutter (23991): #26 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:682:45)
E/flutter (23991): #27 Future._propagateToListeners (dart:async/future_impl.dart:711:32)
E/flutter (23991): #28 Future._completeWithValue (dart:async/future_impl.dart:526:5)
E/flutter (23991): #29 Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:556:7)
E/flutter (23991): #30 _rootRun (dart:async/zone.dart:1184:13)
E/flutter (23991): #31 _CustomZone.run (dart:async/zone.dart:1077:19)
E/flutter (23991): #32 _CustomZone.runGuarded (dart:async/zone.dart:979:7)
E/flutter (23991): #33 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1019:23)
E/flutter (23991): #34 _microtaskLoop (dart:async/schedule_microtask.dart:43:21)
E/flutter (23991): #35 _startMicrotaskLoop (dart:async/schedule_microtask.dart:52:5)
E/flutter (23991):
W/System.err(23991): java.lang.IllegalStateException: Compute signature failed!
W/System.err(23991): at com.alibaba.sdk.android.oss.common.utils.OSSUtils.sign(OSSUtils.java:475)
W/System.err(23991): at com.jlcool.aliossflutter.AliossflutterPlugin$1.signContent(AliossflutterPlugin.java:137)
W/System.err(23991): at com.alibaba.sdk.android.oss.common.utils.OSSUtils.signRequest(OSSUtils.java:699)
W/System.err(23991): at com.alibaba.sdk.android.oss.network.OSSRequestTask.call(OSSRequestTask.java:86)
W/System.err(23991): at com.alibaba.sdk.android.oss.network.OSSRequestTask.call(OSSRequestTask.java:44)
W/System.err(23991): at java.util.concurrent.FutureTask.run(FutureTask.java:237)
W/System.err(23991): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
W/System.err(23991): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
W/System.err(23991): at java.lang.Thread.run(Thread.java:818)
W/System.err(23991): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'byte[] java.lang.String.getBytes(java.lang.String)' on a null object reference
W/System.err(23991): at com.alibaba.sdk.android.oss.common.auth.HmacSHA1Signature.computeSignature(HmacSHA1Signature.java:48)
W/System.err(23991): at com.alibaba.sdk.android.oss.common.utils.OSSUtils.sign(OSSUtils.java:472)
W/System.err(23991): ... 8 more
I/flutter (23991): estimateMaxScrollOffset: firstIndex: 0, lastIndex: 2
I/flutter (23991): didFinishLayout: firstIndex: 0, lastIndex: 2
I/flutter (23991): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (23991): │ #0 OssHelper.ossUploadFile2.<anonymous closure> (package:qzone_app/helper/OssHelper.dart:84:18)
I/flutter (23991): │ #1 _rootRunUnary (dart:async/zone.dart:1192:38)
I/flutter (23991): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (23991): │ 💡 url 签名 :http://qzone-pic1.oss-cn-hangzhou.aliyuncs.com/2020/06/16/82bfe28a56a3e8bb4f52b0b4524bc8a2.jpg
I/flutter (23991): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
W/System.err(23991): java.lang.IllegalStateException: Compute signature failed!
W/System.err(23991): at com.alibaba.sdk.android.oss.common.utils.OSSUtils.sign(OSSUtils.java:475)
W/System.err(23991): at com.jlcool.aliossflutter.AliossflutterPlugin$1.signContent(AliossflutterPlugin.java:137)
W/System.err(23991): at com.alibaba.sdk.android.oss.common.utils.OSSUtils.signRequest(OSSUtils.java:699)
W/System.err(23991): at com.alibaba.sdk.android.oss.network.OSSRequestTask.call(OSSRequestTask.java:86)
W/System.err(23991): at com.alibaba.sdk.android.oss.network.OSSRequestTask.call(OSSRequestTask.java:239)
W/System.err(23991): at com.alibaba.sdk.android.oss.network.OSSRequestTask.call(OSSRequestTask.java:44)
W/System.err(23991): at java.util.concurrent.FutureTask.run(FutureTask.java:237)
W/System.err(23991): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
W/System.err(23991): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
W/System.err(23991): at java.lang.Thread.run(Thread.java:818)
W/System.err(23991): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'byte[] java.lang.String.getBytes(java.lang.String)' on a null object reference
W/System.err(23991): at com.alibaba.sdk.android.oss.common.auth.HmacSHA1Signature.computeSignature(HmacSHA1Signature.java:48)
W/System.err(23991): at com.alibaba.sdk.android.oss.common.utils.OSSUtils.sign(OSSUtils.java:472)
W/System.err(23991): ... 9 more
W/System.err(23991): com.alibaba.sdk.android.oss.ClientException: Compute signature failed!
W/System.err(23991): [ErrorMessage]: Compute signature failed!
W/System.err(23991): at com.alibaba.sdk.android.oss.network.OSSRequestTask.call(OSSRequestTask.java:200)
W/System.err(23991): at com.alibaba.sdk.android.oss.network.OSSRequestTask.call(OSSRequestTask.java:239)
W/System.err(23991): at com.alibaba.sdk.android.oss.network.OSSRequestTask.call(OSSRequestTask.java:239)
W/System.err(23991): at com.alibaba.sdk.android.oss.network.OSSRequestTask.call(OSSRequestTask.java:44)
W/System.err(23991): at java.util.concurrent.FutureTask.run(FutureTask.java:237)
W/System.err(23991): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
W/System.err(23991): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
W/System.err(23991): at java.lang.Thread.run(Thread.java:818)
W/System.err(23991): Caused by: java.lang.IllegalStateException: Compute signature failed!
W/System.err(23991): at com.alibaba.sdk.android.oss.common.utils.OSSUtils.sign(OSSUtils.java:475)
W/System.err(23991): at com.jlcool.aliossflutter.AliossflutterPlugin$1.signContent(AliossflutterPlugin.java:137)
W/System.err(23991): at com.alibaba.sdk.android.oss.common.utils.OSSUtils.signRequest(OSSUtils.java:699)
W/System.err(23991): at com.alibaba.sdk.android.oss.network.OSSRequestTask.call(OSSRequestTask.java:86)
W/System.err(23991): ... 7 more
W/System.err(23991): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'byte[] java.lang.String.getBytes(java.lang.String)' on a null object reference
W/System.err(23991): at com.alibaba.sdk.android.oss.common.auth.HmacSHA1Signature.computeSignature(HmacSHA1Signature.java:48)
W/System.err(23991): at com.alibaba.sdk.android.oss.common.utils.OSSUtils.sign(OSSUtils.java:472)
W/System.err(23991): ... 10 more
I/flutter (23991): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (23991): │ #0 OssHelper.ossUploadFile2.<anonymous closure> (package:qzone_app/helper/OssHelper.dart:104:16)
I/flutter (23991): │ #1 _rootRunUnary (dart:async/zone.dart:1192:38)
I/flutter (23991): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (23991): │ 💡 data.success:false
I/flutter (23991): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (23991): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (23991): │ #0 OssHelper.ossUploadFile2.<anonymous closure> (package:qzone_app/helper/OssHelper.dart:105:16)
I/flutter (23991): │ #1 _rootRunUnary (dart:async/zone.dart:1192:38)
I/flutter (23991): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (23991): │ 💡 data.key:2020/06/16/82bfe28a56a3e8bb4f52b0b4524bc8a2.jpg
I/flutter (23991): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (23991): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (23991): │ #0 OssHelper.ossUploadFile2.<anonymous closure> (package:qzone_app/helper/OssHelper.dart:106:16)
I/flutter (23991): │ #1 _rootRunUnary (dart:async/zone.dart:1192:38)
I/flutter (23991): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (23991): │ 💡 data.msg:Compute signature failed!
I/flutter (23991): │ 💡 [ErrorMessage]: Compute signature failed!
I/flutter (23991): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (23991): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (23991): │ #0 OssHelper.ossUploadFile2.<anonymous closure> (package:qzone_app/helper/OssHelper.dart:107:16)
I/flutter (23991): │ #1 _rootRunUnary (dart:async/zone.dart:1192:38)
I/flutter (23991): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (23991): │ 💡 data.servercallback:null
I/flutter (23991): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (23991): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (23991): │ #0 OssHelper.ossUploadFile2.<anonymous closure> (package:qzone_app/helper/OssHelper.dart:114:18)
I/flutter (23991): │ #1 _rootRunUnary (dart:async/zone.dart:1192:38)
I/flutter (23991): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (23991): │ 💡 上传失败
I/flutter (23991): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
请问我是哪里搞错了?
W/System.err(20405): android.os.NetworkOnMainThreadException
W/System.err(20405): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1147)
W/System.err(20405): at java.net.InetAddress.lookupHostByName(InetAddress.java:418)
W/System.err(20405): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252)
W/System.err(20405): at java.net.InetAddress.getByName(InetAddress.java:305)
W/System.err(20405): at com.alibaba.sdk.android.oss.common.utils.OSSUtils.isValidateIP(OSSUtils.java:795)
W/System.err(20405): at com.alibaba.sdk.android.oss.OSSImpl.(OSSImpl.java:133)
W/System.err(20405): at com.alibaba.sdk.android.oss.OSSClient.(OSSClient.java:116)
W/System.err(20405): at com.jlcool.aliossflutter.AliossflutterPlugin.init(AliossflutterPlugin.java:250)
W/System.err(20405): at com.jlcool.aliossflutter.AliossflutterPlugin.onMethodCall(AliossflutterPlugin.java:100)
W/System.err(20405): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:226)
W/System.err(20405): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
W/System.err(20405): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:631)
W/System.err(20405): at android.os.MessageQueue.nativePollOnce(Native Method)
W/System.err(20405): at android.os.MessageQueue.next(MessageQueue.java:143)
W/System.err(20405): at android.os.Looper.loop(Looper.java:122)
W/System.err(20405): at android.app.ActivityThread.main(ActivityThread.java:5305)
W/System.err(20405): at java.lang.reflect.Method.invoke(Native Method)
W/System.err(20405): at java.lang.reflect.Method.invoke(Method.java:372)
W/System.err(20405): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:922)
W/System.err(20405): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:717)
W/System.err(20405): android.os.NetworkOnMainThreadException
W/System.err(20405): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1147)
W/System.err(20405): at java.net.InetAddress.lookupHostByName(InetAddress.java:418)
W/System.err(20405): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252)
W/System.err(20405): at java.net.InetAddress.getByName(InetAddress.java:305)
W/System.err(20405): at com.alibaba.sdk.android.oss.common.utils.OSSUtils.isValidateIP(OSSUtils.java:795)
W/System.err(20405): at com.alibaba.sdk.android.oss.OSSImpl.(OSSImpl.java:133)
W/System.err(20405): at com.alibaba.sdk.android.oss.OSSClient.(OSSClient.java:116)
W/System.err(20405): at com.alibaba.sdk.android.oss.OSSClient.(OSSClient.java:104)
W/System.err(20405): at com.jlcool.aliossflutter.AliossflutterPlugin.secretInit(AliossflutterPlugin.java:144)
W/System.err(20405): at com.jlcool.aliossflutter.AliossflutterPlugin.onMethodCall(AliossflutterPlugin.java:102)
W/System.err(20405): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:226)
W/System.err(20405): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
W/System.err(20405): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:631)
W/System.err(20405): at android.os.MessageQueue.nativePollOnce(Native Method)
W/System.err(20405): at android.os.MessageQueue.next(MessageQueue.java:143)
W/System.err(20405): at android.os.Looper.loop(Looper.java:122)
W/System.err(20405): at android.app.ActivityThread.main(ActivityThread.java:5305)
W/System.err(20405): at java.lang.reflect.Method.invoke(Native Method)
W/System.err(20405): at java.lang.reflect.Method.invoke(Method.java:372)
W/System.err(20405): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:922)
W/System.err(20405): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:717)
在主线程里访问网络了
我想直接用AccessKey这种方式上传文件,如何做
升级 Flutter 1.17.0后,用xcode打包(Archive)出现
Module 'aliossflutter' not found
由外部传入一个Future,返回指定格式的参数,而不是由你自己实现sts server的调用,可以参考腾讯云cos的sdk。
https://github.com/tencentyun/cos-js-sdk-v5
getAuthorization
看了半天,关键变量的含义模棱两可的,难受啊。
可能是个好东西,研究半天又用不上。。
可否规范一下代码注释和文档啊···
duplicate symbol '_channel' in:
XXX/aliossflutter/libaliossflutter.a(AliossflutterPlugin.o)
XXX/fluwx_no_pay/libfluwx_no_pay.a(FluwxPlugin.o)
ld: 1 duplicate symbol for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
去掉 fluwx 可以正常运行
flutter build apk打包报错,大佬看看是怎么回事?
`
FAILURE: Build failed with an exception.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Android resource linking failed
C:\Users\liwei.gradle\caches\transforms-2\files-2.1\f33c8b8bc23bc2e3545b322ef8025849\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/fontVariationSettings not found.
C:\Users\liwei\.gradle\caches\transforms-2\files-2.1\f33c8b8bc23bc2e3545b322ef8025849\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/ttcIndex not found.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 57s
`
secretInit 与 init 相同?
init的请求token 我需要自行完成 所以是否可以用secretInit
E:\work\app>flutter build apk
You are building a fat APK that includes binaries for android-arm, android-arm64, android-x64.
If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size.
To generate an app bundle, run:
flutter build appbundle --target-platform android-arm,android-arm64,android-x64
Learn more on: https://developer.android.com/guide/app-bundle
To split the APKs per ABI, run:
flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi
Learn more on: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
Running Gradle task 'assembleRelease'...
ע: D:\Program Files\flutter.pub-cache\hosted\pub.flutter-io.cn\aliossflutter-0.0.4\android\src\main\java\com\jlcool\aliossflutter\AliossflutterPlugin.javaʹ����δ������ȫ�IJ�����
ע: �й���ϸ��Ϣ, ��ʹ�� -Xlint:unchecked ���±��롣
FAILURE: Build failed with an exception.
Execution failed for task ':aliossflutter:verifyReleaseResources'.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Android resource linking failed
C:\Users\jywl\.gradle\caches\transforms-2\files-2.1\a528b13ac93e64cafa3d0480e2c93207\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/fontVariationSettings not found.
C:\Users\jywl\.gradle\caches\transforms-2\files-2.1\a528b13ac93e64cafa3d0480e2c93207\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/ttcIndex not found.
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
我引入包之后,调用init或者secretInit。控制台返回提示,未找到这两个方法的实现。
MissingPluginException(No implementation found for method secretInit on channel aliossflutter)
下面是我的代码
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:aliossflutter/aliossflutter.dart';
import 'dart:async';
import './page/root/dynamic.dart';
import './page/root/shop.dart';
import './page/root/center.dart';
import 'package:flutter/services.dart';
import 'package:flutter_app/components/toats.dart';
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
PageController _controller;
int page = 0;
static DateTime _startedTime;
final String accessKeyId = "LTAI0pnKdX7I5Rk1";
final String accessKeySecret = "AkYIfYsvjpaBYzqL86f7xv8yNOfc1X";
final String endpoint = "http://oss-cn-hangzhou.aliyuncs.com";
AliOSSFlutter alioss = AliOSSFlutter();
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
void initState() {
super.initState();
_controller = new PageController(initialPage: this.page, keepPage: true);
Timer(Duration(milliseconds: 1000),
() => {alioss.secretInit(accessKeyId, accessKeySecret, endpoint)});
alioss.responseFromInit.listen((data) {
print(data);
});
}
void onTap(int index) {
setState(() {
this.page = index;
_controller.jumpToPage(page);
});
}
void _onPageChanged(int page) {
setState(() {
this.page = page;
});
}
@override
Widget build(BuildContext context) {
ScreenUtil.instance = ScreenUtil(width: 750, height: 1334)..init(context);
return WillPopScope(
onWillPop: listenerKeyBack,
child: Scaffold(
body: new PageView(
physics: NeverScrollableScrollPhysics(),
controller: _controller,
onPageChanged: _onPageChanged,
children: <Widget>[new Dynamic(), new Shop(), new CenterMy()],
),
bottomNavigationBar: Container(
height: ScreenUtil().setWidth(90),
width: ScreenUtil().setWidth(750),
color: Colors.black,
child: new BottomNavigationBar(
selectedFontSize: ScreenUtil().setWidth(0),
unselectedFontSize: ScreenUtil().setWidth(0),
iconSize: ScreenUtil().setWidth(50),
backgroundColor: Color(0xffF3F3F3),
items: [
new BottomNavigationBarItem(
icon: Icon(Icons.home), title: Text('')),
new BottomNavigationBarItem(
icon: Icon(Icons.shopping_cart), title: Text('')),
new BottomNavigationBarItem(
icon: Icon(Icons.people), title: Text(''))
],
currentIndex: page,
onTap: onTap))),
);
}
// 监听返回键
Future<bool> listenerKeyBack() async {
if (_startedTime == null) {
_startedTime = new DateTime.now();
Toast.toast(context, '再次点击退出');
} else {
SystemChannels.platform.invokeMethod('SystemNavigator.pop');
}
// 等待两秒
await Future.delayed(Duration(milliseconds: 2000));
// 2秒后移除toast
if (DateTime.now().difference(_startedTime).inMilliseconds >= 2000) {
_startedTime = null;
}
return Future.value(false);
}
}
init credential1
"signalStrengthChanged:info:",
"cellChanged:cell:",
"connectionStateChanged:connection:dataConnectionStatusInfo:",
"carrierBundleChange:"
)
get token error: Error Domain=NSURLErrorDomain Code=-1002 "unsupported URL" UserInfo={NSUnderlyingError=0x6000008baaf0 {Error Domain=kCFErrorDomainCFNetwork Code=-1002 "(null)"}, NSErrorFailingURLStringKey=, NSErrorFailingURLKey=, NSLocalizedDescription=unsupported URL}
"signalStrengthChanged:info:",
"cellChanged:cell:",
"connectionStateChanged:connection:dataConnectionStatusInfo:",
"carrierBundleChange:"
)
Unsupported value: Error Domain=com.aliyun.oss.clientError Code=1 "(null)" UserInfo={ErrorMessage=Can't get a federation token} of type NSError
"signalStrengthChanged:info:",
"cellChanged:cell:",
"connectionStateChanged:connection:dataConnectionStatusInfo:",
"carrierBundleChange:"
)
"signalStrengthChanged:info:",
"cellChanged:cell:",
"connectionStateChanged:connection:dataConnectionStatusInfo:",
"carrierBundleChange:"
)
因为aliossflutter使用还有点问题,所以我在项目里面把aliossflutter相关的代码就先注释掉了
包括在pubspec.yaml里面的,也注释了,现在在ios上准备打包
执行:
pod update --verbose --no-repo-update
时报错:
Fetching external sources
-> Fetching podspec for Flutter
from Flutter
-> Fetching podspec for aliossflutter
from .symlinks/plugins/aliossflutter/ios
[!] No podspec found for aliossflutter
in .symlinks/plugins/aliossflutter/ios
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/external_sources/path_source.rb:14:in block in fetch' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/user_interface.rb:64:in
section'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/external_sources/path_source.rb:11:in fetch' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer/analyzer.rb:980:in
fetch_external_source'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer/analyzer.rb:959:in block (2 levels) in fetch_external_sources' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer/analyzer.rb:958:in
each'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer/analyzer.rb:958:in block in fetch_external_sources' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/user_interface.rb:64:in
section'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer/analyzer.rb:957:in fetch_external_sources' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer/analyzer.rb:117:in
analyze'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer.rb:410:in analyze' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer.rb:235:in
block in resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/user_interface.rb:64:in section' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer.rb:234:in
resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer.rb:156:in install!' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/command/update.rb:63:in
run'
/Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in run' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/command.rb:52:in
run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/bin/pod:55:in <top (required)>' /usr/local/bin/pod:23:in
load'
/usr/local/bin/pod:23:in `
STS的key和secret应该保存在后端,由前端以http形式向后端请求token。前端拿到token之后再向oss服务器发送上传/下载请求。flutter作为前段,应该只保留这几个功能:
pub上只有0.0.4版本,打apk包会出错,切换到到github最新的源后,克隆下来的库文件夹是空的。
Could not find a file named "pubspec.yaml" in "D:\flutter.pub-cache\git\aliossflutter-94ebf9aa0a4f4e0a57fd19b090748acd579e500b".
pub get failed (66; Could not find a file named "pubspec.yaml" in "D:\flutter.pub-cache\git\aliossflutter-94ebf9aa0a4f4e0a57fd19b090748acd579e500b".)
如题,config里面的字段不知道怎么填,希望作者大大能加上注释,非常感谢!!
你好,请问该插件是否支持并行上传下载?
AliossflutterPlugin 中
String jsonText = IOUtils.readStreamAsString(input, OSSConstants.DEFAULT_CHARSET_NAME);
我得到的结果是
{
"StatusCode": 200,
"AccessKeyId": "STS.NJ3KZnNKJasGNm4GHm4LfbqEo",
"AccessKeySecret": "686HQPMGA3pwDgkAGtJhRkae2KiS8yfBzwDYdkbKeUvS",
"SecurityToken": "CAISjQJ1q6Ft5B2yfSjIr4mGAODao5Rr1rGsTEuFo0g4OMNKjbTujTz2IHlMfHRrCOgbvv0/nGpR6foZlqp6U4cdhqk3qQE1vPpt6gqET9fria7ctM456vCMHWyUFGSMvqv7aPn4S9XwY+qkb0u++AZ43br9c0fNPTGiKobby+QkDLItUxK/cCBNCfpPOwJms7V6D3bKMuu3OROY5Qi1BUFz6A1nkjE9u+btgO/ks0aC0gGmkLVP/tqufsX+MfMBZskvD42Hu8VtbbfE3SJq7BxHybx7lqQs+02c54nFXgIAu0jWarqMqIQwcFRjFaE+Gr9Zqv/njuF/ueHVmInxxgxEIeZPSSPbSZBWaB068XoJXBqAAQ3MB/zSkl5fKriO5kj2OFMI5+STc8c5M2lCDYbktHcES90iSwTMORi7MBPbxY8axVHc7nzuHDQ5RAkBin/y9A/kKhCtfoPQylceceGMatFAq26mJRbz/vGh1nCnRP9nYP+im4dLy41KEVH/rmgAJ2yFzSSvdmA9pId+lM7Pnv0c",
"Expiration": "2019-04-16T09:42:30Z"
}
之后两行要执行
String dec = jsonObj.getString("Data");
但是其实我的这个jsonObj并没有Data这个字段,这时候会报错
W/System.err(25626): org.json.JSONException: No value for Data
W/System.err(25626): at org.json.JSONObject.get(JSONObject.java:389)
W/System.err(25626): at org.json.JSONObject.getString(JSONObject.java:550)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.