Easier access to the variant of a blob

上级 710957b2
require "active_storage/service"
require "active_storage/filename"
require "active_storage/purge_job"
require "active_storage/variant"
# Schema: id, key, filename, content_type, metadata, byte_size, checksum, created_at
class ActiveStorage::Blob < ActiveRecord::Base
......@@ -40,6 +41,10 @@ def filename
ActiveStorage::Filename.new(self[:filename])
end
def variant(variation)
ActiveStorage::Variant.new(self, variation: variation)
end
def url(expires_in: 5.minutes, disposition: :inline)
service.url key, expires_in: expires_in, disposition: disposition, filename: filename
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册