Sha256: 4322253e136f0c4f0adb957303268acb04bf110ba0a28cca1a808c1a91f1bbec

Contents?: true

Size: 870 Bytes

Versions: 9

Compression:

Stored size: 870 Bytes

Contents

module Writefully
  module Storage
    class << self 
      def directory
        @directory ||= connection.directories.get(Writefully.options[:storage_folder])
      end

      def store_file(path, body)
        directory.files.create({
          key: path,
          body: body,
          public: true
        })
      end

      def endpoint
        provider_endpoints[Writefully.options[:storage_provider].downcase.to_sym]
      end

      def provider_endpoints
        { aws: "https://#{Writefully.options[:storage_folder]}.s3.amazonaws.com"}
      end

      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]
        })
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
writefully-0.4.8 lib/writefully/storage.rb
writefully-0.4.7 lib/writefully/storage.rb
writefully-0.4.6 lib/writefully/storage.rb
writefully-0.4.5 lib/writefully/storage.rb
writefully-0.4.4 lib/writefully/storage.rb
writefully-0.4.2 lib/writefully/storage.rb
writefully-0.4.1 lib/writefully/storage.rb
writefully-0.4.0 lib/writefully/storage.rb
writefully-0.3.6 lib/writefully/storage.rb