TF-56 Add object upload request & response and widget builder
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
class FileInfo with EquatableMixin {
|
||||
final String fileName;
|
||||
final String filePath;
|
||||
final int fileSize;
|
||||
|
||||
FileInfo(this.fileName, this.filePath, this.fileSize);
|
||||
|
||||
factory FileInfo.empty() {
|
||||
return FileInfo('', '', 0);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object> get props => [fileName, filePath, fileSize];
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:model/model.dart';
|
||||
|
||||
class UploadRequest with EquatableMixin {
|
||||
|
||||
final Uri uploadUrl;
|
||||
final FileInfo fileInfo;
|
||||
final AccountId accountId;
|
||||
final AccountRequest accountRequest;
|
||||
|
||||
UploadRequest(this.uploadUrl, this.accountId, this.fileInfo, this.accountRequest);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [uploadUrl, accountId, fileInfo, accountRequest];
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:http_parser/http_parser.dart';
|
||||
import 'package:jmap_dart_client/http/converter/account_id_converter.dart';
|
||||
import 'package:jmap_dart_client/http/converter/id_converter.dart';
|
||||
import 'package:jmap_dart_client/http/converter/media_type_converter.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/unsigned_int.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:model/email/attachment.dart';
|
||||
|
||||
part 'upload_response.g.dart';
|
||||
|
||||
@AccountIdConverter()
|
||||
@MediaTypeConverter()
|
||||
@IdConverter()
|
||||
@JsonSerializable()
|
||||
class UploadResponse with EquatableMixin {
|
||||
|
||||
final AccountId accountId;
|
||||
final Id blobId;
|
||||
final MediaType type;
|
||||
final int size;
|
||||
|
||||
UploadResponse(this.accountId, this.blobId, this.type, this.size);
|
||||
|
||||
factory UploadResponse.fromJson(Map<String, dynamic> json) => _$UploadResponseFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$UploadResponseToJson(this);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [accountId, blobId, type, size];
|
||||
}
|
||||
|
||||
extension UploadResponseExtension on UploadResponse {
|
||||
Attachment toAttachmentFile(String nameFile) {
|
||||
return Attachment(blobId: blobId, size: UnsignedInt(size), name: nameFile, type: type);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user