46 lines
1.2 KiB
Ruby
46 lines
1.2 KiB
Ruby
module StorageAdapters
|
|
class BaseAdapter
|
|
def initialize(storage_location)
|
|
@storage_location = storage_location
|
|
end
|
|
|
|
# Scan for video files and return array of relative paths
|
|
def scan
|
|
raise NotImplementedError, "#{self.class} must implement #scan"
|
|
end
|
|
|
|
# Generate streaming URL for a video
|
|
def stream_url(video)
|
|
raise NotImplementedError, "#{self.class} must implement #stream_url"
|
|
end
|
|
|
|
# Check if file exists at path
|
|
def exists?(file_path)
|
|
raise NotImplementedError, "#{self.class} must implement #exists?"
|
|
end
|
|
|
|
# Check if storage can be read from
|
|
def readable?
|
|
raise NotImplementedError, "#{self.class} must implement #readable?"
|
|
end
|
|
|
|
# Check if storage can be written to
|
|
def writable?
|
|
@storage_location.writable?
|
|
end
|
|
|
|
# Write/copy file to storage
|
|
def write(source_path, dest_path)
|
|
raise NotImplementedError, "#{self.class} must implement #write"
|
|
end
|
|
|
|
# Download file to local temp path (for processing)
|
|
def download_to_temp(video)
|
|
raise NotImplementedError, "#{self.class} must implement #download_to_temp"
|
|
end
|
|
|
|
protected
|
|
|
|
attr_reader :storage_location
|
|
end
|
|
end |