module Writefully::Storage

Public Class Methods

connection() click to toggle source
# File lib/writefully/storage.rb, line 28
def connection
  @connection ||= Fog::Storage.new({
    provider:              Writefully.options[:storage_provider],
    aws_access_key_id:     Writefully.options[:storage_key],
    aws_secret_access_key: Writefully.options[:storage_secret],
    region:                Writefully.options[:storage_region]
  })
end
directory() click to toggle source
# File lib/writefully/storage.rb, line 4
def directory
  @directory ||= connection.directories.get(Writefully.options[:storage_folder])
end
endpoint() click to toggle source
# File lib/writefully/storage.rb, line 20
def endpoint
  Writefully.options[:assets_host] || provider_endpoints[Writefully.options[:storage_provider].downcase.to_sym]
end
provider_endpoints() click to toggle source
# File lib/writefully/storage.rb, line 24
def provider_endpoints
  { aws: "https://#{Writefully.options[:storage_folder]}.s3.amazonaws.com"}
end
remove_file(key) click to toggle source
# File lib/writefully/storage.rb, line 16
def remove_file(key)
  directory.files.get(key).destroy
end
store_file(path, body) click to toggle source
# File lib/writefully/storage.rb, line 8
def store_file(path, body)
  directory.files.create({
    key: path,
    body: body,
    public: true
  })
end