|
|
@ -3,6 +3,8 @@ part of '../neon_files.dart'; |
|
|
|
abstract interface class FilesBlocEvents { |
|
|
|
abstract interface class FilesBlocEvents { |
|
|
|
void uploadFile(final List<String> path, final String localPath); |
|
|
|
void uploadFile(final List<String> path, final String localPath); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void uploadBytes(final List<String> path, final Uint8List bytes); |
|
|
|
|
|
|
|
|
|
|
|
void syncFile(final List<String> path); |
|
|
|
void syncFile(final List<String> path); |
|
|
|
|
|
|
|
|
|
|
|
void openFile(final List<String> path, final String etag, final String? mimeType); |
|
|
|
void openFile(final List<String> path, final String etag, final String? mimeType); |
|
|
@ -159,7 +161,7 @@ class FilesBloc extends InteractiveBloc implements FilesBlocEvents, FilesBlocSta |
|
|
|
void uploadFile(final List<String> path, final String localPath) { |
|
|
|
void uploadFile(final List<String> path, final String localPath) { |
|
|
|
wrapAction( |
|
|
|
wrapAction( |
|
|
|
() async { |
|
|
|
() async { |
|
|
|
final task = FilesUploadTask( |
|
|
|
final task = FilesUploadFileTask( |
|
|
|
path: path, |
|
|
|
path: path, |
|
|
|
file: File(localPath), |
|
|
|
file: File(localPath), |
|
|
|
); |
|
|
|
); |
|
|
@ -171,6 +173,22 @@ class FilesBloc extends InteractiveBloc implements FilesBlocEvents, FilesBlocSta |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
|
|
|
void uploadBytes(final List<String> path, final Uint8List bytes) { |
|
|
|
|
|
|
|
wrapAction( |
|
|
|
|
|
|
|
() async { |
|
|
|
|
|
|
|
final task = FilesUploadBytesTask( |
|
|
|
|
|
|
|
path: path, |
|
|
|
|
|
|
|
bytes: bytes, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
tasks.add(tasks.value..add(task)); |
|
|
|
|
|
|
|
await _uploadQueue.add(() => task.execute(account.client)); |
|
|
|
|
|
|
|
tasks.add(tasks.value..removeWhere((final t) => t == task)); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
disableTimeout: true, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Future<File> _cacheFile(final List<String> path, final String etag) async { |
|
|
|
Future<File> _cacheFile(final List<String> path, final String etag) async { |
|
|
|
final cacheDir = await getApplicationCacheDirectory(); |
|
|
|
final cacheDir = await getApplicationCacheDirectory(); |
|
|
|
final file = File(p.join(cacheDir.path, 'files', etag.replaceAll('"', ''), path.last)); |
|
|
|
final file = File(p.join(cacheDir.path, 'files', etag.replaceAll('"', ''), path.last)); |
|
|
@ -190,7 +208,7 @@ class FilesBloc extends InteractiveBloc implements FilesBlocEvents, FilesBlocSta |
|
|
|
final List<String> path, |
|
|
|
final List<String> path, |
|
|
|
final File file, |
|
|
|
final File file, |
|
|
|
) async { |
|
|
|
) async { |
|
|
|
final task = FilesDownloadTask( |
|
|
|
final task = FilesDownloadFileTask( |
|
|
|
path: path, |
|
|
|
path: path, |
|
|
|
file: file, |
|
|
|
file: file, |
|
|
|
); |
|
|
|
); |
|
|
|