halo-sigs / plugin-alioss

【过时】为 Halo 2.0 提供阿里云 OSS 的存储策略。请使用 S3 插件替代:https://github.com/halo-sigs/plugin-s3
https://halo.run/store/apps/app-Qxhpp
GNU General Public License v3.0
10 stars 4 forks source link

阿里云 Endpoint 配置不正确导致无法正常显示图片 #5

Closed llllike closed 1 year ago

llllike commented 1 year ago

这个字段一定不要带https:// QQ图片20221208172459 如果带了https:// 图片能上传到阿里云,阿里云控制台也能正常打开图片,但是halo网页无法显示图片

JohnNiang commented 1 year ago

有一个专门用于设置协议的设置项:”绑定域名协议”,所以这里得 Endpoint 就只需要填写域名即可。

ruibaby commented 1 year ago

/kind improvement

可以考虑优化一下,加一个校验。

JohnNiang commented 1 year ago

plugin-alioss 1.0.1 已经解决了这个问题,可下载测试。

/close

f2c-ci-robot[bot] commented 1 year ago

@JohnNiang: Closing this issue.

In response to [this](https://github.com/halo-sigs/plugin-alioss/issues/5#issuecomment-1359099216): >[plugin-alioss 1.0.1](https://github.com/halo-sigs/plugin-alioss/releases/tag/v1.0.1) 已经解决了这个问题,可下载测试。 > >/close Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
longjuan commented 1 year ago

@JohnNiang 呃呃,我的那个PR好像没对endpoint做验证,只对domain做了验证。 另外我发现如果endpoint没加上协议头,他自动会加上http的协议头,如下图 image 如果要做验证是否在buildClient的时候额外加上https://更安全,还是说再给一个协议选择的设置来控制?

JohnNiang commented 1 year ago

Hi @longjuan ,从官方文档和源码上看,设置 endpoint 时,可以加上 protocol,并且优先级比 client 的 protocol 更高。不过为了更加安全,可以试着设置以下 client 的 protocol 为 https:

    OSS buildOss(AliOssProperties properties) {
        var config = new ClientBuilderConfiguration();
        config.setProtocol(Protocol.HTTPS);
        return OSSClientBuilder.create()
            .endpoint(properties.getEndpoint())
            .credentialsProvider(new DefaultCredentialProvider(properties.getAccessKey(),
                properties.getAccessSecret()))
            .clientConfiguration(config)
            .build() ;
    }
longjuan commented 1 year ago

Hi @longjuan ,从官方文档和源码上看,设置 endpoint 时,可以加上 protocol,并且优先级比 client 的 protocol 更高。不过为了更加安全,可以试着设置以下 client 的 protocol 为 https:

    OSS buildOss(AliOssProperties properties) {
        var config = new ClientBuilderConfiguration();
        config.setProtocol(Protocol.HTTPS);
        return OSSClientBuilder.create()
            .endpoint(properties.getEndpoint())
            .credentialsProvider(new DefaultCredentialProvider(properties.getAccessKey(),
                properties.getAccessSecret()))
            .clientConfiguration(config)
            .build() ;
    }

好的,我来提个PR?

JohnNiang commented 1 year ago

/reopen /assign @longjuan

f2c-ci-robot[bot] commented 1 year ago

@JohnNiang: Reopened this issue.

In response to [this](https://github.com/halo-sigs/plugin-alioss/issues/5#issuecomment-1360916469): >/reopen >/assign @longjuan Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.