Giter Club home page Giter Club logo

aws-s3-raku's Introduction

WebService::AWS::S3

Client for Amazon Web Services' Simple Storage Service

SparrowCI

Synopsis

use WebService::AWS::S3;

my $secret-access-key = 'passw0rd';
my $access-key-id = 'password1';
my $region = 'us-east-1';

my \s3 = S3.new(:$secret-access-key, :$access-key-id, :$region);

s3.put:
   content => "Hello, world!!",
   url     => "s3://my.own.bucket/hello/world.txt";

say s3.get("s3://my.own.bucket/hello/world.txt");

Description

This module provide a client for Amazon's S3 web service.

If you encounter a feature of S3 you want that's not implemented by this module (and there are many), please consider sending a pull request.

Overview

WebService::AWS::S3 implements commands like get, put, list-buckets, and list-objects.

WebService::AWS::S3::Resources implement resources like S3::Bucket and S3::Object.

Examples

These all assume the environment variables AWS_SECRET_ACCESS_KEY and AWS_ACCESS_KEY_ID have been set.

  • Print the contents of the first object in the first bucket.
use WebService::AWS::S3;

my \s3 = S3.new(:region<us-east-1>);
my $bucket-list = s3.list-buckets;
my $bucket      = $bucket-list[0] // die 'no buckets';
my $object-list = s3.list-objects(:$bucket);
my $object      = $object-list[0] // die "no objects in { $bucket.name }";
my $content     = s3.get($object);
say $content;
  • Get contents from a known S3 bucket and key.
use WebService::AWS::S3;

my \s3 = S3.new(:region<us-east-1>);
say s3.get("s3://my.own.bucket/hello/world.txt")
  • Put text to an S3 location.
use WebService::AWS::S3;

my \s3 = S3.new(:region<us-east-1>);
my $content = "Hello, world!";
my $url     = "s3://my.own.bucket/hello/world.txt";
say s3.put(:$content, :$url);

TODO

A lot.

aws-s3-raku's People

Contributors

bduggan avatar jonathanstowe avatar melezhik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

aws-s3-raku's Issues

Private S3 Compatible Services

Hi, how can I construct an \s3 object which talks to other software speaking the S3 protocol? In my instance a MiniIO server running locally. I tried passing in $url to the constructor but looks like this isn't possible at the moment.

my $url = 'http://127.0.0.1:9000';
my \s3 = S3.new(:$secret-access-key, :$access-key-id, :$url, :$region);

Include x-amz-security-token in headers if provided

My application is running in EC2 and needs to obtain the "temporary" security credentials for the IAM role at run-time ( using Kivuli), this requires that the provided security token is included in the request:

If you're using temporary security credentials from the AWS Security Token Service, you must include the security token

( documented here)

otherwise one gets:

<Error><Code>InvalidAccessKeyId</Code><Message>The AWS Access Key Id you provided does not exist in our records.</Message><AWSAccessKeyId>ASIASITX6WPJ2MG7EBOU</AWSAccessKeyId><RequestId>VDZRSZFW47Y8STVT</RequestId><HostId>tjSbxnVmqoP7ruWqOPEbnNdAIzuc3PLhX2wt6oh7yf9ATeiggx8rKTy4hEUGDAvOox3WRTlY3t8=</HostId></Error>

So it would probably be add an optional $.security-token to the constructor of S3 and also S3::Request and add the x-amz-security-token to the signing headers.

This is more of a reminder for me to do this, unless you have something down the back of the sofa already.

Binary candidates for `put`, `get`

Right now it's not possible to deal with "binary" files such as images and so forth, and it would be nice to do so.

Given that HTTP::UserAgent deals quite well with binary payloads I don't think this would be that hard to do and if I get a minute I'll take a look.

Tests fail

On rakudo 2019.11:

โžœ  ~ zef install WebService::AWS::S3
===> Searching for: WebService::AWS::S3
===> Searching for missing dependencies: XML::Class, URI::Encode, IO::Socket::SSL, HTTP::UserAgent, Digest, Digest::HMAC, URI
===> Searching for missing dependencies: XML, HTTP::Status, File::Temp, DateTime::Parse, Encode, MIME::Base64, IO::Capture::Simple, Test::Util::ServerPort
===> Searching for missing dependencies: File::Directory::Tree
===> Testing: XML:ver<0.3.0>:auth<Timothy Totten>
===> Testing [OK] for XML:ver<0.3.0>:auth<Timothy Totten>
===> Testing: XML::Class:ver<0.0.7>:auth<github:jonathanstowe>:api<1.0>
===> Testing [OK] for XML::Class:ver<0.0.7>:auth<github:jonathanstowe>:api<1.0>
===> Testing: URI::Encode:ver<0.08>
===> Testing [OK] for URI::Encode:ver<0.08>
===> Testing: IO::Socket::SSL:ver<0.0.1>:auth<github:sergot>
[IO::Socket::SSL] # NETWORK_TESTING was not set
===> Testing [OK] for IO::Socket::SSL:ver<0.0.1>:auth<github:sergot>
===> Testing: HTTP::Status
===> Testing [OK] for HTTP::Status
===> Testing: File::Directory::Tree:auth<labster>
===> Testing [OK] for File::Directory::Tree:auth<labster>
===> Testing: File::Temp:ver<0.0.6>
===> Testing [OK] for File::Temp:ver<0.0.6>
===> Testing: DateTime::Parse:ver<0.9.1>
===> Testing [OK] for DateTime::Parse:ver<0.9.1>
===> Testing: Encode:ver<0.0.2>:auth<github:sergot>
===> Testing [OK] for Encode:ver<0.0.2>:auth<github:sergot>
===> Testing: MIME::Base64:ver<1.2.1>:auth<github:retupmoca>
===> Testing [OK] for MIME::Base64:ver<1.2.1>:auth<github:retupmoca>
===> Testing: URI:ver<0.3.0>
===> Testing [OK] for URI:ver<0.3.0>
===> Testing: IO::Capture::Simple
===> Testing [OK] for IO::Capture::Simple
===> Testing: Test::Util::ServerPort:ver<0.0.2>:auth<github:jonathanstowe>:api<1.0>
===> Testing [OK] for Test::Util::ServerPort:ver<0.0.2>:auth<github:jonathanstowe>:api<1.0>
===> Testing: HTTP::UserAgent:ver<1.1.48>:auth<github:sergot>
[HTTP::UserAgent] # NETWORK_TESTING was not set
[HTTP::UserAgent] # NETWORK_TESTING was not set
[HTTP::UserAgent] # NETWORK_TESTING was not set
[HTTP::UserAgent] # NETWORK_TESTING was not set
[HTTP::UserAgent] # NETWORK_TESTING was not set
[HTTP::UserAgent] # NETWORK_TESTING was not set
===> Testing [OK] for HTTP::UserAgent:ver<1.1.48>:auth<github:sergot>
===> Testing: Digest:ver<0.3.4>:auth<Lucien Grondin>
===> Testing [OK] for Digest:ver<0.3.4>:auth<Lucien Grondin>
===> Testing: Digest::HMAC:ver<1.0.0>:auth<github:retupmoca>
===> Testing [OK] for Digest::HMAC:ver<1.0.0>:auth<github:retupmoca>
===> Testing: WebService::AWS::S3:ver<0.0.2>:auth<github:bduggan>
[WebService::AWS::S3] set AWS_TEST_BUCKET and AWS_TEST_PREFIX to run live tests
[WebService::AWS::S3] Cannot resolve caller split(URI::Path:D, Str:D); Routine does not have any candidates. Is only the proto defined?
[WebService::AWS::S3]   in method request at t/05-mock.t line 14
[WebService::AWS::S3]   in method do-request at /home/koto/.zef/store/WebService-AWS-S3-0.0.2.tar.gz/WebService-AWS-S3-0.0.2/lib/WebService/AWS/S3.pm6 (WebService::AWS::S3) line 79
[WebService::AWS::S3]   in method list-buckets at /home/koto/.zef/store/WebService-AWS-S3-0.0.2.tar.gz/WebService-AWS-S3-0.0.2/lib/WebService/AWS/S3.pm6 (WebService::AWS::S3) line 103
[WebService::AWS::S3]   in block <unit> at t/05-mock.t line 34
===> Testing [FAIL]: WebService::AWS::S3:ver<0.0.2>:auth<github:bduggan>
Aborting due to test failure: WebService::AWS::S3:ver<0.0.2>:auth<github:bduggan> (use --force-test to override)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.