-
fn create_s3_operator(
storage_server_id: Uuid,
options: &ObjectServerOption,
) -> anyhow::Result<Operator> {
let endpoint = &options.endpoint;
let access_key_id = &options.access_key_id;
let secret_access_key = &options.secret_access_key;
let region = &options.region;
let bucket = &options.default_bucket;
let mut builder = S3::default();
builder
.endpoint(endpoint)
.root(&format!("storage-{}", storage_server_id))
.bucket(bucket)
.region(region)
.access_key_id(access_key_id)
.secret_access_key(secret_access_key)
.allow_anonymous()
.build()?;
Ok(Operator::new(builder)?.finish())
}
async fn upload(
&self,
storage_server: &StorageServer,
meta_id: Uuid,
content: &[u8],
) -> ... {
...
let operator = create_s3_operator(storage_server.id, options)?;
operator.write(&meta_id.to_string(), content.to_owned()).await?;
...
} in my expectation, this operator will create a file named And I find that the build info has logged twice:
|
Beta Was this translation helpful? Give feedback.
Answered by
Xuanwo
Sep 4, 2023
Replies: 1 comment 1 reply
-
Please don't call let mut builder = S3::default();
builder
.endpoint(endpoint)
.root(&format!("storage-{}", storage_server_id))
.bucket(bucket)
.region(region)
.access_key_id(access_key_id)
.secret_access_key(secret_access_key)
.allow_anonymous();
Ok(Operator::new(builder)?.finish()) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
zooeywm
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please don't call
builder.build?
directly, it will take and consumebuilder
itself. Instead: