createThumbnailUploadVideoData method

Future<T> createThumbnailUploadVideoData(
  1. String memberMediumDocumentID,
  2. Uint8List fileData,
  3. String baseName,
  4. String thumbnailBaseName, {
  5. FeedbackProgress? feedbackProgress,
})

Implementation

Future<T> createThumbnailUploadVideoData(String memberMediumDocumentID,
    Uint8List fileData, String baseName, String thumbnailBaseName,
    {FeedbackProgress? feedbackProgress}) async {
  print('MemberMediumHelper.createThumbnailUploadVideoData: $baseName');

  // First, upload the file
  var fileInfo = await UploadInfo.uploadData(baseName, fileData,
      app.documentID, ownerId, packageName, readAccessCustomMetaData(),
      feedbackProgress: (progress) => _feedBackAggregatedProgress(
          1, 4, progress,
          feedbackProgress: feedbackProgress));

  if (fileInfo == null) {
    throw Exception(
        'Unable to upload file with baseName $baseName. Could not create fileInfo');
  }

  // Second, create the thumbnail
  var enrichedVideo = await MediumData.enrichVideoWithHardcodedThumbnail(
    baseName,
    thumbnailBaseName,
    fileData, /*fileInfo.url*/
  );
  _feedBackAggregatedProgress(2, 4, 1, feedbackProgress: feedbackProgress);

  // Third, upload the thumbnail;
  var fileInfoThumbnail = await UploadInfo.uploadData(
      thumbnailBaseName,
      enrichedVideo.thumbNailData.data,
      app.documentID,
      ownerId,
      packageName,
      readAccessCustomMetaData(),
      feedbackProgress: (progress) => _feedBackAggregatedProgress(
          3, 4, progress,
          feedbackProgress: feedbackProgress));
  if (fileInfoThumbnail == null) {
    throw Exception(
        'Unable to upload file with baseName $baseName. Could not create fileInfoThumbnail');
  }

  var returnMe = await videoWithThumbnailToMediumModel(memberMediumDocumentID,
      baseName, fileInfo, fileInfoThumbnail, enrichedVideo);
  _feedBackAggregatedProgress(4, 4, 1, feedbackProgress: feedbackProgress);
  return returnMe;
}