Giter Club home page Giter Club logo

rust-s3's Introduction

MIT licensed

rust-s3 - Documentation

Tiny Rust library for working with Amazon S3

Increasingly more loosly based on crates.io implementation.

Intro

Very modest interface towards Amazon S3. Supports put, get and list, with delete on the roadmap and will be done eventually, probably around the time I discover I need it in some other project :).

What is cool

The main (and probably only) cool feature is that put commands return a presigned link to the file you uploaded. This means you can upload to s3, and give the link to select people without having to worry about publicly accessible files on S3.

Configuration

Getter and setter functions exist for all Link params... You don't really have to touch anything there, maybe amz-expire, it is configured for one week which is the maximum Amazon allows ATM.

Usage

In your Cargo.toml

[dependencies]
rust-s3 = '0.2.3'

Example

extern crate s3;
use s3::{Bucket, put_s3, get_s3, list_s3};

const AWS_ACCESS: &'static str = "access_key";
const AWS_SECRET: &'static str = "secret_key";

fn main () {
  // Bucket instance
  let bucket = Bucket::new(S3_BUCKET.to_string(),
                              None,
                              AWS_ACCESS.to_string(),
                              AWS_SECRET.to_string(),
                              None);

  // Put
  let put_me = "I want to go to S3".to_string();
  let url = put_s3(&bucket,
                  &"/",
                  &put_me.as_bytes());
  println!("{}", url);

  // List
  let bytes = list_s3(&bucket,
                      &"/",
                      &"/",
                      &"/");
  let string = String::from_utf8_lossy(&bytes);
  println!("{}", string);

  // Get
  let path = &"test_file";
  let mut buffer = match File::create(path) {
            Ok(x) => x,
            Err(e) => panic!("{:?}, {}", e, path)
          };
  let bytes = get_s3(&bucket, Some(&path));
  match buffer.write(&bytes) {
    Ok(_) => {} // info!("Written {} bytes from {}", x, path),
    Err(e) => panic!("{:?}", e)
  }
}

rust-s3's People

Contributors

durch avatar jseyfried avatar

Watchers

 avatar

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.