2017-07-01 06:10:11 -04:00
|
|
|
# Abstract class serving as an interface for concrete sites.
|
2017-07-06 05:33:29 -04:00
|
|
|
class ActiveStorage::Site
|
2017-07-04 10:44:50 -04:00
|
|
|
def self.configure(site, **options)
|
|
|
|
begin
|
2017-07-06 05:33:29 -04:00
|
|
|
require "active_storage/site/#{site.to_s.downcase}_site"
|
|
|
|
ActiveStorage::Site.const_get(:"#{site}Site").new(**options)
|
2017-07-04 12:52:11 -04:00
|
|
|
rescue LoadError => e
|
|
|
|
puts "Couldn't configure site: #{site} (#{e.message})"
|
2017-07-04 10:44:50 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-06-30 18:04:19 -04:00
|
|
|
|
2017-07-04 10:05:06 -04:00
|
|
|
def upload(key, io)
|
2017-07-01 06:10:11 -04:00
|
|
|
raise NotImplementedError
|
2017-06-30 13:12:58 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def download(key)
|
2017-07-01 06:10:11 -04:00
|
|
|
raise NotImplementedError
|
2017-06-30 13:12:58 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def delete(key)
|
2017-07-01 06:10:11 -04:00
|
|
|
raise NotImplementedError
|
2017-06-30 13:12:58 -04:00
|
|
|
end
|
|
|
|
|
2017-07-03 15:08:36 -04:00
|
|
|
def exist?(key)
|
2017-07-01 06:10:11 -04:00
|
|
|
raise NotImplementedError
|
2017-06-30 13:12:58 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2017-07-04 11:34:37 -04:00
|
|
|
def url(key, expires_in:, disposition:, filename:)
|
2017-07-01 06:10:11 -04:00
|
|
|
raise NotImplementedError
|
2017-06-30 13:12:58 -04:00
|
|
|
end
|
|
|
|
|
2017-07-04 11:00:36 -04:00
|
|
|
def bytesize(key)
|
2017-07-01 06:10:11 -04:00
|
|
|
raise NotImplementedError
|
2017-06-30 13:12:58 -04:00
|
|
|
end
|
|
|
|
|
2017-07-04 11:00:36 -04:00
|
|
|
def checksum(key)
|
2017-07-01 06:10:11 -04:00
|
|
|
raise NotImplementedError
|
2017-06-30 13:12:58 -04:00
|
|
|
end
|
2017-06-30 18:14:22 -04:00
|
|
|
end
|