Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os: fix bug (copy path not support chinese characters) #134

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tardis/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ ws-client = ["future", "tokio-tungstenite", "tls"]
cache = ["futures-util", "redis", "deadpool-redis"]
mq = ["futures-util", "lapin", "amq-protocol-types", "async-global-executor"]
mail = ["lettre"]
os = ["async-trait", "anyhow", "rust-s3"]
os = ["async-trait", "anyhow", "rust-s3", "urlencoding"]
k8s = ["future", "kube", "k8s-openapi"]
fs = ["tokio/fs", "tokio/io-util"]
process = ["tokio/process"]
Expand Down Expand Up @@ -85,6 +85,7 @@ url = { version = "2.2", features = ["serde"] }
lru = { version = "0.12.0" }
typed-builder = { version = "0.18" }
paste = { version = "1.0" }
urlencoding = { version = "2" , optional = true }
# Tokio
tokio = { version = "1", features = [
"macros",
Expand Down
2 changes: 1 addition & 1 deletion tardis/src/os/os_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ impl TardisOSOperations for TardisOSS3Client {

async fn object_copy(&self, from: &str, to: &str, bucket_name: Option<&str>) -> TardisResult<()> {
let bucket = self.get_bucket(bucket_name)?;
bucket.copy_object_internal(from, to).await?;
bucket.copy_object_internal(urlencoding::encode(from), to).await?;
Ok(())
}

Expand Down
4 changes: 3 additions & 1 deletion tardis/tests/test_os_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ async fn test_os_client() -> TardisResult<()> {
let data = TardisFuns::os().object_get("test/test.txt", Some(bucket_name)).await?;
assert_eq!(String::from_utf8(data).unwrap(), "I want to go to S3 测试");

TardisFuns::os().object_copy("test/test.txt", "test/test_cp.txt", Some(bucket_name)).await?;
TardisFuns::os().object_copy("test/test.txt", "test/test复制.txt", Some(bucket_name)).await?;
TardisFuns::os().object_copy("test/test复制.txt", "test/test_cp.txt", Some(bucket_name)).await?;
let data = TardisFuns::os().object_get("test/test_cp.txt", Some(bucket_name)).await?;
assert_eq!(String::from_utf8(data).unwrap(), "I want to go to S3 测试");

Expand All @@ -41,6 +42,7 @@ async fn test_os_client() -> TardisResult<()> {
assert_eq!(String::from_utf8(data).unwrap(), "I want to go to S3 测试");

TardisFuns::os().object_delete("test/test.txt", Some(bucket_name)).await?;
TardisFuns::os().object_delete("test/test复制.txt", Some(bucket_name)).await?;
TardisFuns::os().object_delete("test/test_cp.txt", Some(bucket_name)).await?;
assert!(TardisFuns::os().object_get("test/test.txt", Some(bucket_name)).await.is_err());

Expand Down
Loading