Skip to content

feat: 更换 oss 的 sdk #92

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

feat: 更换 oss 的 sdk #92

wants to merge 3 commits into from

Conversation

tu6ge
Copy link

@tu6ge tu6ge commented Apr 1, 2025

No description provided.

@pluveto
Copy link
Owner

pluveto commented Apr 1, 2025

  1. 设置值为 https://oss-cn-shanghai.aliyuncs.com 是考虑到用户使用的可能是自己部署的版本或者自定义的域名
  2. 需要保持前向兼容,更换后之前的 oss 用户应该能正常使用

@tu6ge
Copy link
Author

tu6ge commented Apr 1, 2025

我看有两个设置项,这个设置只用于上传接口调用,另外一个host可以用于返回上传的网址

@pluveto
Copy link
Owner

pluveto commented Apr 1, 2025

需要保证用户升级后能不改配置使用

@tu6ge
Copy link
Author

tu6ge commented Apr 1, 2025

嗯,有道理,我改下

@CatSouta
Copy link
Contributor

CatSouta commented Apr 11, 2025

用户配置的 Endpoint 可以是自定义域名,阿里云 OSS 支持使用自定义域名进行上传操作,但修改后仍然不支持使用自定义域名进行文件上传。

参考:
绑定自定义域名至OSS传输加速域名

@tu6ge
Copy link
Author

tu6ge commented Apr 11, 2025

@CatSouta 这里的 host 是不是可选的配置

https://github.com/pluveto/upgit/blob/main/config.sample.toml#L117

@tu6ge
Copy link
Author

tu6ge commented Apr 11, 2025

endpoint = "https://oss-cn-shanghai.aliyuncs.com"

这个配置,可能是自定义域名吗?如果涉及到 bucket 内部文件读取,上传,下载等功能的时候,是需要在这个域名前面拼接 [bucketname].

@CatSouta
Copy link
Contributor

@CatSouta 这里的 host 是不是可选的配置

https://github.com/pluveto/upgit/blob/main/config.sample.toml#L117

host 是用来输出非 {bucket}.oss-{region_id}.aliyuncs.com 的图片链接的,也可以说是 CDN 链接。它可以作为可选配置,但目前是必须填写的,可以稍作修改。

@CatSouta
Copy link
Contributor

endpoint = "https://oss-cn-shanghai.aliyuncs.com"

这个配置,可能是自定义域名吗?如果涉及到 bucket 内部文件读取,上传,下载等功能的时候,是需要在这个域名前面拼接 [bucketname].

Endpoint 只是对象储存的连接端点,只是用来连接对象储存所在的服务器,而传入的 bucket 值才是用来找到具体的桶对文件对象进行相关处理的。你所说的{bucket}.oss-{region_id}.aliyuncs.com这样的域名是用来直接访问 OSS 桶中的文件或者说,这种地址可以用来使用阿里云 OSS 官方提供的 API。(参考1)
例如,如果我的 OSS 开启了传输加速功能,那么我使用的 Endpoint 就会是自定义域名{bucket}.oss-accelerate.aliyuncs.com。(参考2)

你更换的 SDK 看起来是通过 HTTP API 实现的,那确实需要通过{bucket}.oss-{region_id}.aliyuncs.com这样的域名来进行 API 的请求。(参考3)

可以多翻阅一下官方文档,能找到很多内容。

参考:
OSS API 简介
加速OSS资源远距离上传和下载
Go SDK V2快速入门

@tu6ge
Copy link
Author

tu6ge commented Apr 11, 2025

@CatSouta 我看过相应的文档,如果要使用加速域名的话,就不应该修改 endpoint 配置吧,应该修改 host 配置吧

加速域名是对于 bucket 来说的吧,而不是针对的 endpoint

@CatSouta
Copy link
Contributor

@CatSouta 我看过相应的文档,如果要使用加速域名的话,就不应该修改 endpoint 配置吧,应该修改 host 配置吧

加速域名是对于 bucket 来说的吧,而不是针对的 endpoint

加速传输和CDN加速域名并非同一个东西,加速传输是用来加速上传的,而CDN加速域名是用来加速访问/下载文件的。

@tu6ge
Copy link
Author

tu6ge commented Apr 11, 2025

你的意思是说 endpoint 的值可能是 {bucket}.oss-accelerate.aliyuncs.com ?

@CatSouta
Copy link
Contributor

你的意思是说 endpoint 的值可能是 {bucket}.oss-accelerate.aliyuncs.com ?

具体可以参考:https://help.aliyun.com/zh/oss/user-guide/enable-transfer-acceleration#section-gtt-hyd-vba

@tu6ge
Copy link
Author

tu6ge commented Apr 11, 2025

你的意思是说 endpoint 的值可能是 {bucket}.oss-accelerate.aliyuncs.com ?

具体可以参考:https://help.aliyun.com/zh/oss/user-guide/enable-transfer-acceleration#section-gtt-hyd-vba

我可以升级版本支持这个,另外如果要支持自定义加速域名的话,你希望用户如何配置呢

@CatSouta
Copy link
Contributor

你的意思是说 endpoint 的值可能是 {bucket}.oss-accelerate.aliyuncs.com ?

具体可以参考:https://help.aliyun.com/zh/oss/user-guide/enable-transfer-acceleration#section-gtt-hyd-vba

我可以升级版本支持这个,另外如果要支持自定义加速域名的话,你希望用户如何配置呢

上面只是解释 Endpoint 相关,目的是需要你更换的 SDK 能够支持目前用户不修改配置文件的情况下能正常使用。其他的具体还是看你怎么去完善和支持了。

@tu6ge
Copy link
Author

tu6ge commented Apr 12, 2025

配置保持原样,保持原有功能目前已支持

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.

3 participants