durch / rust-s3

Rust library for interfacing with S3 API compatible services
MIT License
498 stars 195 forks source link

delete_object method return 403 SignatureDoesNotMatch Error. #382

Open maojinhua opened 2 months ago

maojinhua commented 2 months ago

Describe the bug I can use put_object method and get_object method successfully,but when I delete_object method return 403 SignatureDoesNotMatch Error.

error desicribe

thread 'uploader::tests::upload_file' panicked at src/uploader.rs:108:59:
called `Result::unwrap()` on an `Err` value: Http(403, "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Error><Code>SignatureDoesNotMatch</Code><RequestId>tx0000000000000005782b9-0066164d99-57823ee-object-store-pool</RequestId><HostId>57823ee-object-store-pool-object-store-pool</HostId></Error>")
stack backtrace:

To Reproduce test code like this

 #[tokio::test]
    async fn upload_file() {
        let region = Region::Custom {
            region: "".into(),
            endpoint: ENDPOINT.to_string(),
        };

        let credentials = Credentials::new(
            Some(&ACCESS_KEY.to_string()),
            Some(&SECRET_KEY.to_string()),
            None,
            None,
            None,
        )
        .unwrap();

        let mut bucket = Bucket::new(&BUCKET_NAME.to_string(), region, credentials)
            .unwrap()
            .with_path_style();

        let path = "test.txt";
        let content = Bytes::from_static(b"test content");
        let response_data = bucket.put_object(path, content.chunk()).await.unwrap();

        assert_eq!(response_data.status_code(), 200);

        let resp = bucket.get_object("test.txt").await.unwrap();
        assert_eq!(resp.status_code(), 200);

        let resp = bucket.delete_object("test.txt").await.unwrap();
        assert_eq!(resp.status_code(), 200);
    }

cargo.toml file

[package]
name = "aps"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
# -- Web
axum = "0.7.5"
tower-http = { version = "0.5.2", features = ["catch-panic", "trace"] }
http = "1.1.0"
# -- Serde
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.68"
# -- Async
tokio = { version = "1.0", features = ["full"] }
# -- Log
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }

# -- Database
sea-orm = { version = "0.12.15", features = [
    "debug-print",
    "runtime-tokio-native-tls",
    "sqlx-mysql",
    "mock",
] }

rust-s3 = { version = "0.33.0" }

# -- Others
toml = "0.7.4"
bytes = "1.6.0"
chrono = "0.4"
clap = { version = "4.5.4", features = ["derive"] }
tempfile = "3.10.1"

[dev-dependencies]
tower = { version = "0.4", features = ["util"] }
http-body-util = "0.1.0"
reqwest = "0.12.3"

Expected behavior i expected delete successfully .thanks!

Environment