rafidgotit / media_picker_widget

A widget that picks media files from storage and allows you to place anywhere in the widget tree.
MIT License
13 stars 14 forks source link

Media class missing original image info #11

Closed laeo closed 11 months ago

laeo commented 11 months ago

Picked photos cannot get its original bytes or File object or MIME info, and i can't have filename.

static MediaViewModel _toMediaViewModel(AssetEntity entity) {
    var mediaType = MediaType.all;
    if (entity.type == AssetType.video) mediaType = MediaType.video;
    if (entity.type == AssetType.image) mediaType = MediaType.image;
    return MediaViewModel(
      id: entity.id,
      thumbnailAsync: entity.thumbnailDataWithSize(ThumbnailSize(200, 200)),
      type: mediaType,
      thumbnail: null,
      videoDuration: entity.type == AssetType.video ? entity.videoDuration : null,
    );
  }

I see AssetEntity has originFile and mimeTypeAsync attributes, we can take original image info from originFile, and its mime info from mimeTypeAsync, so we can rename or manipulate it more preciesly.