mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 15:24:35 +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
|
||||
|
||||
Reference in New Issue
Block a user