mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-18 07:44:26 +01:00
#33 new: upload file to sftp from file picker
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import '../server/server_private_info.dart';
|
||||
import 'worker.dart';
|
||||
|
||||
@@ -24,6 +26,7 @@ class SftpReqStatus {
|
||||
final SftpReqItem item;
|
||||
final void Function() notifyListeners;
|
||||
late SftpWorker worker;
|
||||
final Completer? completer;
|
||||
|
||||
String get fileName => item.localPath.split('/').last;
|
||||
|
||||
@@ -38,12 +41,11 @@ class SftpReqStatus {
|
||||
required this.item,
|
||||
required this.notifyListeners,
|
||||
required SftpReqType type,
|
||||
String? key,
|
||||
this.completer,
|
||||
}) : id = DateTime.now().microsecondsSinceEpoch {
|
||||
worker = SftpWorker(
|
||||
onNotify: onNotify,
|
||||
item: item,
|
||||
privateKey: key,
|
||||
type: type,
|
||||
);
|
||||
worker.init();
|
||||
@@ -61,6 +63,7 @@ class SftpReqStatus {
|
||||
status = event;
|
||||
if (status == SftpWorkerStatus.finished) {
|
||||
worker.dispose();
|
||||
completer?.complete();
|
||||
}
|
||||
break;
|
||||
case double:
|
||||
|
||||
@@ -12,7 +12,6 @@ import 'req.dart';
|
||||
class SftpWorker {
|
||||
final Function(Object event) onNotify;
|
||||
final SftpReqItem item;
|
||||
final String? privateKey;
|
||||
final SftpReqType type;
|
||||
|
||||
final worker = Worker();
|
||||
@@ -21,7 +20,6 @@ class SftpWorker {
|
||||
required this.onNotify,
|
||||
required this.item,
|
||||
required this.type,
|
||||
this.privateKey,
|
||||
});
|
||||
|
||||
void dispose() {
|
||||
@@ -37,7 +35,7 @@ class SftpWorker {
|
||||
isolateMessageHandler,
|
||||
errorHandler: print,
|
||||
);
|
||||
worker.sendMessage(SftpReq(item: item, privateKey: privateKey, type: type));
|
||||
worker.sendMessage(SftpReq(item: item, type: type));
|
||||
}
|
||||
|
||||
/// Handle the messages coming from the isolate
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:toolbox/core/provider_base.dart';
|
||||
|
||||
import '../model/sftp/req.dart';
|
||||
@@ -25,12 +27,12 @@ class SftpProvider extends ProviderBase {
|
||||
return found.first;
|
||||
}
|
||||
|
||||
void add(SftpReqItem item, SftpReqType type, {String? key}) {
|
||||
void add(SftpReqItem item, SftpReqType type, {Completer? completer}) {
|
||||
_status.add(SftpReqStatus(
|
||||
item: item,
|
||||
notifyListeners: notifyListeners,
|
||||
key: key,
|
||||
type: type,
|
||||
completer: completer,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
class BuildData {
|
||||
static const String name = "ServerBox";
|
||||
static const int build = 341;
|
||||
static const int build = 343;
|
||||
static const String engine = "3.10.2";
|
||||
static const String buildAt = "2023-05-31 19:23:57.263324";
|
||||
static const int modifications = 6;
|
||||
static const String buildAt = "2023-06-01 16:27:31.059809";
|
||||
static const int modifications = 4;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user