uploadVideo method
Future<void>
uploadVideo(
- BuildContext context,
- AppModel app,
- AccessRightsProvider accessRightsProvider,
- MediumAvailable feedbackFunction,
- FeedbackProgress? feedbackProgress,
override
Implementation
@override
Future<void> uploadVideo(
BuildContext context,
AppModel app,
AccessRightsProvider accessRightsProvider,
MediumAvailable feedbackFunction,
FeedbackProgress? feedbackProgress) async {
try {
var ownerId = AccessBloc.memberId(context);
if (ownerId == null) {
throw Exception("Expecting to have a member logged in to take a photo");
}
var memberMediumDocumentID = newRandomKey();
var result = await FilePicker.platform
.pickFiles(type: FileType.video, allowMultiple: false);
if (result == null) {
feedbackFunction(null);
return;
}
var aFile = result.files[0];
var bytes = aFile.bytes;
if (bytes == null) {
feedbackFunction(null);
return;
}
var name = aFile.name;
var baseName = '$memberMediumDocumentID.$name';
print('uploadVideo.baseName: $baseName');
var thumbnailBaseName =
BaseNameHelper.thumbnailBaseName(memberMediumDocumentID, name);
var memberMediumModel = await accessRightsProvider()
.getMediumHelper(app, ownerId)
.createThumbnailUploadVideoData(
memberMediumDocumentID, bytes, baseName, thumbnailBaseName,
feedbackProgress: feedbackProgress);
feedbackFunction(memberMediumModel);
} catch (error) {
print('Error trying to uploadVideo: $error');
feedbackFunction(null);
}
}