依赖
qiniu_flutter_sdk: ^0.3.0
导入
import 'package:qiniu_flutter_sdk/qiniu_flutter_sdk.dart';
使用
// 创建 storage 对象
Storage storage = Storage();
// 创建 putController 对象
PutController putController = PutController();
// 添加任务进度监听
putController.addProgressListener((double percent) {
print('任务进度变化:已发送:$percent');
});
// 添加文件发送进度监听
putController.addSendProgressListener((double percent) {
print('已上传进度变化:已发送:$percent');
});
// 添加任务状态监听
putController.addStatusListener((StorageStatus status) {
print('状态变化: 当前任务状态:$status');
});
//uuid包
String key = Uuid().v4()+".jpg";
print("初始:$key");
storage.putFile(“file”, "token",options: PutOptions(
controller: putController,
key: key
)).then((PutResponse flag){
print(flag.key);
});
uuid依赖包 uuid: ^3.0.4