Sha256: 5868d751bc650403289110479fae427d8f149165326987e6f6782a1c19ac6488

Contents?: true

Size: 610 Bytes

Versions: 2

Compression:

Stored size: 610 Bytes

Contents

require "fog"
require "open-uri"

class PgbackupsArchive::Storage

  def initialize(key, file)
    @key = key
    @file = file
  end

  def connection
    Fog::Storage.new({
      provider:              "AWS",
      aws_access_key_id:     ENV["PGBACKUPS_AWS_ACCESS_KEY_ID"],
      aws_secret_access_key: ENV["PGBACKUPS_AWS_SECRET_ACCESS_KEY"],
      region:                ENV["PGBACKUPS_REGION"],
      persistent:            false
    })
  end

  def bucket
    connection.directories.get ENV["PGBACKUPS_BUCKET"]
  end

  def store
    bucket.files.create key: @key, body: @file, :public => false
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pgbackups-archive-0.0.3 lib/pgbackups-archive/storage.rb
pgbackups-archive-0.0.1 lib/pgbackups-archive/storage.rb