Closed biebb2024 closed 6 months ago
可以有复现的小 demo,从错误上看 host 好像出现问题。
链接:https://pub.dev/packages/flutter_oss_aliyun#nbsp-client sts后端文档: https://help.aliyun.com/document_detail/100624.html
我是通过自定义得到的 ,然后运行就报了那个错误,但是用官方提供的工具 没问题
我自己试了下,自定义的方式是可以工作的。如果不能提供更多的信息,请对照下面程序,看下区别。
void main() {
setUpAll(() {
Auth _authGetter() {
return Auth(
accessKey: "{accessKey}",
accessSecret: '{accessSecret}',
expire: '2024-03-27T09:38:22Z',
secureToken: '{secure_token}',
);
}
Client.init(
ossEndpoint: "oss-cn-beijing.aliyuncs.com",
bucketName: "{bucket-name}",
authGetter: _authGetter);
});
test("test the put test in Client", () async {
final String string = "Hello World2";
final Response<dynamic> resp = await Client().putObject(
Uint8List.fromList(utf8.encode(string)),
"test-test.txt",
option: PutRequestOption(
onSendProgress: (count, total) {
print("send: count = $count, and total = $total");
},
onReceiveProgress: (count, total) {
print("receive: count = $count, and total = $total");
},
override: true,
aclModel: AclMode.publicRead,
storageType: StorageType.ia,
callback: Callback(
callbackUrl: callbackUrl,
callbackBody:
"{\"mimeType\":\${mimeType}, \"filepath\":\${object},\"size\":\${size},\"bucket\":\${bucket},\"phone\":\${x:phone}}",
callbackVar: {"x:phone": "android"},
calbackBodyType: CalbackBodyType.json,
),
),
);
expect(resp.statusCode, 200);
});
+1,我把 putObject 方法的 url 去掉 bucket 参数就可以了
DioException [connection error]: The connection errored: Failed host lookup: 'kxx-test.http' This indicates an error which most likely cannot be solved by the library. I/flutter ( 2514): Error: SocketException: Failed host lookup: 'kxx-test.http' (OS Error: No address associated with hostname, errno = 7) I/flutter ( 2514): E/flutter ( 2514): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: DioException [connection error]: The connection errored: Failed host lookup: 'kxx-test.http' This indicates an error which most likely cannot be solved by the library. E/flutter ( 2514): Error: SocketException: Failed host lookup: 'kxx-test.http' (OS Error: No address associated with hostname, errno = 7)