-
let shared_config = aws_config::from_env().load().await;
let config = s3::config::Builder::from(&shared_config)
.endpoint_url(S3_ENDPOINT)
.credentials_provider(Credentials::new(ACCESS_KEY_ID,SECRET_ACCESS_KEY,None,None, "simple"))
.region(Region::new(REGION))
.build();
let client = s3::Client::from_conf(config);
// list_buckets success and print all buckets
let buckets = client.list_buckets().send().await?;
for b in buckets.buckets().unwrap_or_default() {
println!("BUCKET: {}",b.name().unwrap_or_default());
}
// but list_objects_v2 failed with error:
// Error: Unhandled(Unhandled { source: DispatchFailure(DispatchFailure { source: ConnectorError
// { kind: Io, source: hyper::Error(Connect, ConnectError("dns error", Custom { kind: Uncategorized, error: "failed to lookup address information:
// Name or service not known" })) } }) })
let objects = client.list_objects_v2().bucket("my-bucket").send().await?;
println!("Objects in bucket:");
for obj in objects.contents().unwrap_or_default() {
println!("{:?}", obj.key().unwrap());
} |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
the "client.list_buckets()" call can sucess, but the next "list_objects_v2" call failed~~ |
Beta Was this translation helpful? Give feedback.
-
Resolved, by enable 'force_path_style=true' in the configuration, |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
Resolved, by enable 'force_path_style=true' in the configuration,
This configuration does not support set in SdkConfig, so it is necessary to modify the creation method of the Client object from
Client::new -> Client::from_ conf