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

feat(presign): support presign head method for s3 and oss #1049

Merged
merged 6 commits into from
Dec 7, 2022

Conversation

ZhiHanZ
Copy link
Contributor

@ZhiHanZ ZhiHanZ commented Dec 7, 2022

I hereby agree to the terms of the CLA available at: https://databend.rs/dev/policies/cla/

Summary

This pull request adds support for generating pre-signed URLs for the HEAD method on Amazon S3 and Aliyun OSS (Object Storage Service) objects.

This allows clients to perform presign head operation on s3 or oss, as an example:

use anyhow::Result;
use futures::io;
use opendal::services::memory;
use opendal::Operator;
use time::Duration;
# use opendal::Scheme;

#[tokio::main]
async fn main() -> Result<()> {
    let op = Operator::from_env(Scheme::Memory)?;
    let signed_req = op.object("test").presign_stat(Duration::hours(1))?;
    let req = http::Request::builder()
        .method(signed_req.method())
        .uri(signed_logreq.uri())
        .body(())?;

    Ok(())
}

This pull request has passed all the necessary checks and tests, including static analysis with cargo check, linting with cargo clippy, unit and integration tests with cargo test, and benchmarking with cargo bench.

src/object/object.rs Outdated Show resolved Hide resolved
src/object/object.rs Outdated Show resolved Hide resolved
src/ops.rs Outdated Show resolved Hide resolved
@ZhiHanZ ZhiHanZ requested a review from Xuanwo December 7, 2022 07:30
tests/behavior/presign.rs Outdated Show resolved Hide resolved
tests/behavior/presign.rs Outdated Show resolved Hide resolved
Copy link
Member

@Xuanwo Xuanwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly LGTM! Thanks for the contribution.

@Xuanwo Xuanwo merged commit 35e05e7 into apache:main Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants