Reputation: 41
How can i get full path to file in ActiveStorage when i use mirror storage settings?
S3 Storage (203.4ms) Uploaded file to key: variants/WptxR3NcEEmEiiinyKk7pNdf/b20b002e6479c04dc24ec29300eae0b6031556b740555f161a7a3951d98cedc4
Disk Storage (0.7ms) Uploaded file to key: variants/WptxR3NcEEmEiiinyKk7pNdf/b20b002e6479c04dc24ec29300eae0b6031556b740555f161a7a3951d98cedc4
My primary storage is S3, but i want get path from Disc Storage.
Upvotes: 1
Views: 1053
Reputation: 41
I found this solution:
item.img.blob.service.mirrors.first.path_for(item.img.blob.key)
or like this:
ActiveStorage::Blob.service.mirrors.first.path_for(item.img.blob.key)
it return full path to img.
Upvotes: 1