Implemented simple and basic file downloading

This commit is contained in:
2023-03-11 20:26:00 +01:00
parent d519bafe3b
commit 54153f1958
12 changed files with 505 additions and 312 deletions

View File

@ -0,0 +1,21 @@
import 'package:marianum_mobile/api/apiResponse.dart';
import 'package:marianum_mobile/api/marianumcloud/webdav/queries/downloadFile/downloadFileParams.dart';
import 'package:marianum_mobile/api/marianumcloud/webdav/webdavApi.dart';
class DownloadFile extends WebdavApi<DownloadFileParams> {
DownloadFileParams params;
DownloadFile(this.params) : super(params);
@override
Future<ApiResponse> run() async {
// final file = await File(localPath).create();
// Uint8List downloadedFile = await (await WebdavApi.webdav).download(params.webdavPath);
// file.writeAsBytesSync(downloadedFile, flush: true, mode: FileMode.write);
//
// OpenFile.open(localPath);
throw UnimplementedError();
}
}

View File

@ -0,0 +1,16 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:marianum_mobile/api/apiParams.dart';
part 'downloadFileParams.g.dart';
@JsonSerializable()
class DownloadFileParams extends ApiParams {
String webdavSourcePath;
String localTargetPath;
String filename;
DownloadFileParams(this.webdavSourcePath, this.localTargetPath, this.filename);
factory DownloadFileParams.fromJson(Map<String, dynamic> json) => _$DownloadFileParamsFromJson(json);
Map<String, dynamic> toJson() => _$DownloadFileParamsToJson(this);
}

View File

@ -0,0 +1,21 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'downloadFileParams.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
DownloadFileParams _$DownloadFileParamsFromJson(Map<String, dynamic> json) =>
DownloadFileParams(
json['webdavSourcePath'] as String,
json['localTargetPath'] as String,
json['filename'] as String,
);
Map<String, dynamic> _$DownloadFileParamsToJson(DownloadFileParams instance) =>
<String, dynamic>{
'webdavSourcePath': instance.webdavSourcePath,
'localTargetPath': instance.localTargetPath,
'filename': instance.filename,
};

View File

@ -0,0 +1,14 @@
import 'package:json_annotation/json_annotation.dart';
part 'downloadFileResponse.g.dart';
@JsonSerializable()
class DownloadFileResponse {
String path;
DownloadFileResponse(this.path);
factory DownloadFileResponse.fromJson(Map<String, dynamic> json) => _$DownloadFileResponseFromJson(json);
Map<String, dynamic> toJson() => _$DownloadFileResponseToJson(this);
}

View File

@ -0,0 +1,19 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'downloadFileResponse.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
DownloadFileResponse _$DownloadFileResponseFromJson(
Map<String, dynamic> json) =>
DownloadFileResponse(
json['path'] as String,
);
Map<String, dynamic> _$DownloadFileResponseToJson(
DownloadFileResponse instance) =>
<String, dynamic>{
'path': instance.path,
};