super-appy / itsumono_obento

今ある材料で作れるレシピを提案するAIレシピとお弁当カレンダー機能で、お弁当作りをサポートするアプリ
6 stars 0 forks source link

S3に画像の保存 #60

Closed super-appy closed 8 months ago

super-appy commented 8 months ago

ActiveStorageを使う:https://railsguides.jp/active_storage_overview.html has_one_attached https://railsguides.jp/active_storage_overview.html#has-one-attached webpに加工して保存するhttps://techblog.gmo-ap.jp/2022/06/13/webp_ex/

super-appy commented 8 months ago

画像を添付したいところ

super-appy commented 8 months ago

画像をS3に上げる、投稿に表示するところまではできた!

しかし、ActiveStorageだと保存前の加工がうまくできなかった。 variantメソッドでできるのは「保存した画像をリサイズして表示」だから、保存時はそのままのサイズで保存されてしまう。 つまり、ストレージの容量が必要になる。

加工して保存できるようにCarrierwaveでの実装に変更する!

super-appy commented 8 months ago

やること

super-appy commented 8 months ago

マイグレーションを削除する ❌ https://qiita.com/ISSO33/items/33a935cb3255c269bef2

pendingが発生したのでロールバックした https://qiita.com/ISSO33/items/33a935cb3255c269bef2

super-appy commented 8 months ago