标签: rusoto

部署时,Docker和"OpenSSL库报告错误"

我通过Amazon Elastic Container Service通过Rust和Rocket提供API.每当我将对象放入或获取到Amazon S3时,它在本地运行良好,但如果部署在Amazon ECS上,我会收到此运行时错误:

HttpDispatch(HttpDispatchError { message: "The OpenSSL library reported an error" })
Run Code Online (Sandbox Code Playgroud)

当我在我的机器上运行Docker镜像时也会发生这种情况.

我添加了错误发生的评论:

use super::types::SomeCustomType;
use rusoto_core::{DefaultCredentialsProvider, Region, default_tls_client};
use rusoto_s3::{S3, S3Client, GetObjectRequest};

pub fn load_data_from_s3(object_name: String) -> SomeCustomType {
    let credentials = DefaultCredentialsProvider::new().unwrap();
    let client = S3Client::new(default_tls_client().unwrap(), credentials, Region::UsWest2);
    let mut request = GetObjectRequest::default();
    request.bucket = "bucket-name".to_string();
    request.key = object_name.to_string();
    match client.get_object(&request) {
        // *** This is going to fail in docker container on run-time ***
        Ok(file) => {
            // this part is actually …
Run Code Online (Sandbox Code Playgroud)

openssl amazon-s3 rust docker rusoto

13
推荐指数
1
解决办法
997
查看次数

使用 rusoto 将字符串上传到 S3

我正在使用rusoto S3 创建一个 JSON 字符串并将此字符串上传到 S3 存储桶。我可以创建字符串,但 rusoto 的 S3PutObjectRequest需要 a StreamingBody,我不确定如何StreamingBody从字符串创建 a ,或者这是否真的有必要。

extern crate json;
extern crate rusoto_core;
extern crate rusoto_s3;
extern crate futures;

use rusoto_core::Region;
use rusoto_s3::{S3, S3Client, PutObjectRequest};

fn main() {
    let mut paths = Vec::new();
    paths.push(1);
    let s3_client = S3Client::new(Region::UsEast1);
    println!("{}", json::stringify(paths));
    s3_client.put_object(PutObjectRequest {
        bucket: String::from("bucket"),
        key: "@types.json".to_string(),
        body: Some(json::stringify(paths)),
        acl: Some("public-read".to_string()),
        ..Default::default()
    }).sync().expect("could not upload");
}
Run Code Online (Sandbox Code Playgroud)

我得到的错误是

extern crate json;
extern crate rusoto_core;
extern crate rusoto_s3;
extern crate …
Run Code Online (Sandbox Code Playgroud)

type-conversion amazon-s3 rust rusoto

9
推荐指数
1
解决办法
2433
查看次数

使用 rusoto 流式上传到 s3

如何使用rusoto将文件上传到 s3 ,而不将文件内容读取到内存(流式传输)?


使用此代码:

use std::fs::File;
use std::io::BufReader;

use rusoto_core::Region;
use rusoto_s3::{PutObjectRequest, S3, S3Client, StreamingBody};

fn main() {
    let file = File::open("input.txt").unwrap();
    let mut reader = BufReader::new(file);

    let s3_client = S3Client::new(Region::UsEast1);
    let result = s3_client.put_object(PutObjectRequest {
        bucket: String::from("example_bucket"),
        key: "example_filename".to_string(),
//        this works:
//      body: Some("example string".to_owned().into_bytes().into()),
//        this doesn't:
        body: Some(StreamingBody::new(reader)),
        ..Default::default()
    }).sync().expect("could not upload");
}
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

error[E0277]: the trait bound `std::io::BufReader<std::fs::File>: futures::stream::Stream` is not satisfied
  --> src/bin/example.rs:18:20
   |
18 |         body: Some(StreamingBody::new(reader)),
   |                    ^^^^^^^^^^^^^^^^^^ the trait …
Run Code Online (Sandbox Code Playgroud)

rust rusoto

8
推荐指数
2
解决办法
2119
查看次数

Rusoto 使用 sigv4 流式上传

我在将上传内容流式传输到 S3 时遇到问题:

// rust version 1.42.0
// OS macos
// [dependencies]
// rusoto_core = "0.43.0"
// rusoto_s3 = "0.43.0"
// log = "0.4"
// pretty_env_logger = "0.4.0"
// tokio = "0.2.14"
// tokio-util = { version = "0.3.1", features = ["codec"] }
// futures = "0.3.4"
// bytes = "0.5.4"

#![allow(dead_code)]
#[allow(unused_imports)]

use log::{debug,info,warn,error};
use bytes::Bytes;
use tokio_util::codec;
use futures::stream::{Stream, TryStreamExt};
use rusoto_core::Region;
use rusoto_s3::{PutObjectRequest, S3, S3Client};
use tokio::io::{AsyncRead, Result};

#[tokio::main]
async fn main() {
    pretty_env_logger::init();
    let pathbuf = …
Run Code Online (Sandbox Code Playgroud)

amazon-s3 rust rusoto

8
推荐指数
1
解决办法
423
查看次数

如何同时使用 actix-web 3 和 rusoto 0.46?

当我尝试同时使用 actix-web 3 和 rusoto 0.46 时,出现以下运行时错误:

thread 'actix-rt:worker:0' panicked at 'there is no reactor running, must be called from the context of a Tokio 1.x runtime', /Users/matt/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.2.0/src/runtime/blocking/pool.rs:85:33
Run Code Online (Sandbox Code Playgroud)

小可复制:

use actix_web::{get, App, HttpResponse, HttpServer, Responder}; // 3
use rusoto_core::Region; // 0.46 
use rusoto_dynamodb::{DynamoDb, DynamoDbClient, ListTablesInput};
use std::default::Default;

#[get("/tables")]
async fn tables(_req_body: String) -> impl Responder {
    let client = DynamoDbClient::new(Region::default());
    let list_tables_input: ListTablesInput = Default::default();
    match client.list_tables(list_tables_input).await {
        Ok(_output) => HttpResponse::Ok().finish(),
        Err(_error) => HttpResponse::InternalServerError().finish(),
    }
}

#[actix_web::main]
async fn main() …
Run Code Online (Sandbox Code Playgroud)

rust rusoto actix-web

7
推荐指数
1
解决办法
719
查看次数

如何将使用 Rusoto 从 S3 下载的文件保存到我的硬盘驱动器?

我正在尝试使用 Rusoto 从存储桶下载文件,并且正在获取文件内容:

fn get_object(client: &TestClient, bucket: &str, filename: &str) {
    let get_req = GetObjectRequest {
        bucket: bucket.to_owned(),
        key: filename.to_owned(),
        ..Default::default()
    };

    let result = client.get_object(&get_req).sync().expect("Couldn't GET object");


    let stream = result.body.unwrap();
    let body = stream.concat2().wait().unwrap();

    assert!(body.len() > 0);
}
Run Code Online (Sandbox Code Playgroud)

如何将此GetObjectOutput(result)对象保存到文件中?

file amazon-s3 file-transfer rust rusoto

3
推荐指数
1
解决办法
2155
查看次数

如何将带有类型参数的结构作为函数参数传递?

如何将EcsClient带有签名的实例impl<P, D> EcsClient<P, D> where P: ProvideAwsCredentials, D: DispatchSignedRequest作为 Rust 中的引用传递给函数?我的尝试是这样的:

extern crate rusoto;

use std::default::Default;

use rusoto::{ DefaultCredentialsProvider, Region };
use rusoto::ecs::{ EcsClient };
use rusoto::default_tls_client;

fn get_task_definition_revisions(client: &EcsClient) {
    // Use EscClient instance here
}

fn main() {
    let provider = DefaultCredentialsProvider::new().unwrap();
    let client = EcsClient::new(default_tls_client().unwrap(), provider, Region::EuWest1).unwrap();

    get_task_definition_revisions(&client);

}
Run Code Online (Sandbox Code Playgroud)

这给了我以下错误:

extern crate rusoto;

use std::default::Default;

use rusoto::{ DefaultCredentialsProvider, Region };
use rusoto::ecs::{ EcsClient };
use rusoto::default_tls_client;

fn get_task_definition_revisions(client: &EcsClient) {
    // Use EscClient …
Run Code Online (Sandbox Code Playgroud)

rust rusoto

2
推荐指数
1
解决办法
4181
查看次数