StorageManager: remove Post-specific code.

Refactor StorageManager to remove all image URL generation code. Instead
the image URL generation code lives in MediaAsset.

Now StorageManager is only concerned with how to read and write files to
remote storage backends like S3 or SFTP, not with how image URLs should
be generated. This way the file storage code isn't tightly coupled to
posts, so it can be used to store any kind of file, not just images
belonging to posts.
This commit is contained in:
evazion
2021-10-26 19:11:37 -05:00
parent afe5095ee6
commit 082544ab03
7 changed files with 33 additions and 172 deletions

View File

@@ -38,7 +38,9 @@ class MediaAsset < ApplicationRecord
end
def open_file
storage_service.open(file_path)
file = storage_service.open(file_path)
frame_data = media_asset.pixiv_ugoira_frame_data&.data if media_asset.is_ugoira?
MediaFile.open(file, frame_data: frame_data)
end
def convert_file(media_file)