0.0
Low commit activity in last 3 years
No release in over a year
Package of AWS features commonly used in Defra Rails based digital services
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

Defra Ruby Aws

Build Status Maintainability Rating Coverage security Gem Version Licence

Package of Ruby helpers for connecting Rails applications to AWS S3.

Installation

Add this line to your application's Gemfile

gem 'defra_ruby_aws'

And then update your dependencies by calling

bundle install

Configuration

Add a new bucket with:

# config/initializers/defra_ruby_aws.rb
require "defra_ruby/aws"

DefraRuby::Aws.configure do |config|
  config.buckets = [{
    # bucket's name, required
    name: "defra-ruby-aws",
    # AWS bucket access credentials, required
    credentials: {
      access_key_id: "ACCESS_KEY_ID",
      secret_access_key: "SECRET_ACCESS_KEY"
    },
    # optional - Default to "eu-west-1"
    region: "eu-west-2",
    # optional - Default to false. Will use AES256
    encrypt_with_kms: true
  }]
end

Usage

Upload a file

file_to_upload = Tempfile.new("test-upload-file.csv")
bucket = DefraRuby::Aws.get_bucket("defra-ruby-aws")
response = bucket.load(file_to_upload)

if response.successful?
  # Do something
else
  response.error # return the failure error
  # Do something else
end

Generate a presigned URL for download

bucket = DefraRuby::Aws.get_bucket("defra-ruby-aws")
presigned_url = bucket.presigned_url("test-upload-file.csv")

Delete a file from the bucket

bucket = DefraRuby::Aws.get_bucket("defra-ruby-aws")
response = bucket.delete("test-upload-file.csv")

if response.successful?
  # Do something
else
  response.error # return the failure error
  # Do something else
end

Contributing to this project

If you have an idea you'd like to contribute please log an issue.

All contributions should be submitted via a pull request.

License

THIS INFORMATION IS LICENSED UNDER THE CONDITIONS OF THE OPEN GOVERNMENT LICENCE found at:

http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3

The following attribution statement MUST be cited in your products and applications when using this information.

Contains public sector information licensed under the Open Government license v3

About the license

The Open Government Licence (OGL) was developed by the Controller of Her Majesty's Stationery Office (HMSO) to enable information providers in the public sector to license the use and re-use of their information under a common open licence.

It is designed to encourage use and re-use of information freely and flexibly, with only a few conditions.