uploadThumbnailAndPhoto method

Future<T> uploadThumbnailAndPhoto(
  1. String memberMediumDocumentID,
  2. String filePath,
  3. String thumbnailPath, {
  4. FeedbackProgress? feedbackProgress,
})

Implementation

Future<T> uploadThumbnailAndPhoto(
    String memberMediumDocumentID, String filePath, String thumbnailPath,
    {FeedbackProgress? feedbackProgress}) async {
  // First, upload the file
  var fileInfo = await UploadInfo.uploadFile(memberMediumDocumentID, filePath,
      app.documentID, ownerId, packageName, readAccessCustomMetaData(),
      homeURL: app.homeURL,
      feedbackProgress: (progress) => _feedBackAggregatedProgress(
          1, 4, progress,
          feedbackProgress: feedbackProgress));

  // Second, create the thumbnail
  // var photoData = await createThumbNailFromPhoto(filePath);
  var baseName = BaseNameHelper.baseName(memberMediumDocumentID, filePath);
  var thumbnailBaseName =
      BaseNameHelper.thumbnailBaseName(memberMediumDocumentID, filePath);

  var enrichedPhoto = await MediumData.enrichPhoto(
      baseName, thumbnailBaseName, fileInfo.item2);
  _feedBackAggregatedProgress(2, 4, 1, feedbackProgress: feedbackProgress);

  // Third, upload the thumbnail;
  var fileInfoThumbnail = await UploadInfo.uploadData(
      thumbnailBaseName,
      enrichedPhoto.thumbNailData.data,
      app.documentID,
      ownerId,
      packageName,
      readAccessCustomMetaData(),
      feedbackProgress: (progress) => _feedBackAggregatedProgress(
          3, 4, progress,
          feedbackProgress: feedbackProgress));

  if (fileInfoThumbnail == null) {
    throw Exception(
        'Unable to upload file $filePath. Could not create thumbnail');
  }

  var returnMe = await photoWithThumbnailToMediumModel(memberMediumDocumentID,
      baseName, fileInfo.item1, fileInfoThumbnail, enrichedPhoto);
  _feedBackAggregatedProgress(4, 4, 1, feedbackProgress: feedbackProgress);
  return returnMe;
}