Project

aion-s3

0.0
No release in over 3 years
Low commit activity in last 3 years
A tool for compressing, encrypting and uploading files to AWS S3
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.17.3
~> 5.11.3
~> 12.3.1

Runtime

 Project Readme

AionS3

This module provides utilities for compressing and encrypting data, as well as uploading compliance locked objects to AWS s3.

AWS credentials

It is possible to read AWS credentials and region information from a file. For more information read documentation for Aws::S3::Client.initialize

Example of file ~/.aws/credentials

[default]
aws_access_key_id=INSERT_ACCESS_KEY_ID_HERE
aws_secret_access_key=INSERT_ACCESS_KEY_HERE
region=eu-north-1

Pack and upload file

require 'aion-s3'

source_path = 'path/to/source/file'
password = "deD4G0pQm41rlPSOgQx59X/gDriMFk0F"
packer = AionS3::Packer.new(password)

packed_body = packer.pack(File.read(source_path, mode: 'rb'))

bucket = 'target-bucket-name'
uploader = AionS3::Uploader.new(bucket, lock_days: 30)

key = 'bucket/path/to/target.packed'
uploader.put(key, packed_body)

Download and unpack file

require 'aion-s3'
    
bucket = 'target-bucket-name'
uploader = AionS3::Uploader.new(bucket)

key = 'bucket/path/to/target.packed'
packed_body = StringIO.open { |io| uploader.get(key, io) }.string

password = "deD4G0pQm41rlPSOgQx59X/gDriMFk0F"
packer = AionS3::Packer.new(password)

body = packer.unpack(packed_body)

target_path = 'path/to/target/file'
File.open(target_path, 'wb') do |file|
  file.write(packer.unpack(packed_body))
end