Function s3::get_s3 [] [src]

pub fn get_s3(bucket: &Bucket,
              s3_path: Option<&str>)
              -> Result<Vec<u8>, curlError>

Gets file from an S3 path

Example:

use s3::{Bucket, get_s3};
use std::io::prelude::*;
use std::fs::File;

let s3_bucket = &"rust-s3-test";
let aws_access = &"access_key";
let aws_secret = &"secret_key";

let bucket = Bucket::new(
              s3_bucket.to_string(),
              None,
              aws_access.to_string(),
              aws_secret.to_string(),
              None);
let path = &"test.file";
let mut buffer = match File::create(path) {
          Ok(x) => x,
          Err(e) => panic!("{:?}, {}", e, path)
        };
let bytes = match get_s3(&bucket, Some(&path)){
 Ok(b) => b,
 Err(e) => {println!("Error: {:?}", e); return;}
};
match buffer.write(&bytes) {
  Ok(_) => {} // info!("Written {} bytes from {}", x, path),
  Err(e) => panic!("{:?}", e)
}