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

图片带有特殊符号上传后无法访问 #42

Open
guqing opened this issue May 17, 2023 · 5 comments
Open

图片带有特殊符号上传后无法访问 #42

guqing opened this issue May 17, 2023 · 5 comments
Labels
kind/improvement Categorizes issue or PR as related to a improvement.

Comments

@guqing
Copy link
Member

guqing commented May 17, 2023

比如现有文件名 111F32F1B9D-中文 &%s/?.asdasd+123.jpeg 上传到 aliyun oss 后生成的 permalink 无法访问。
原因是其中的 + & :没有被 URL encode 而在 aliyun oss 那边是被 encode 了的导致结果不同而无法访问,UriUtils.encodePath 是不会 encode 这几个字符的

所以如果要解决这几个问题我想到两种可能:

  1. 直接使用 s3 平台上传后生成的访问链接以解决两边生成的不一致的问题
  2. 上传到 s3 前对文件名称进行处理去除掉特殊字符

/kind improvement

@f2c-ci-robot f2c-ci-robot bot added the kind/improvement Categorizes issue or PR as related to a improvement. label May 17, 2023
@longjuan
Copy link
Member

longjuan commented Jul 4, 2023

平台生成的链接只有在CompleteMultipartUploadResponse中存在,在接口方法getPermalink中无法获取。
image
image

@longjuan
Copy link
Member

longjuan commented Jul 4, 2023

在接口方法getPermalink中无法获取。

或者设置一个Annotations可以实现。

@guqing
Copy link
Member Author

guqing commented Jul 6, 2023

或者设置一个Annotations可以实现。

上传完成之后将 oss 返回的访问链接存储到 annotations 中应该是可行的

@longjuan
Copy link
Member

对于文件名为的文件:1(1)1$F3@2F1_B9D-中文 &%s.as^d!asd+123.png
腾讯云返回的路径:/test/1(1)1$F3@2F1_B9D-中文 &%s.as^d!asd+123.png
阿里云返回的路径:/test/1%281%291%24F3%402F1_B9D-%E4%B8%AD%E6%96%87%20%26%25s.as%5Ed%21asd%2B123.png
如果单纯采用厂商返回的路径,那么对于腾讯云这类厂商会发生错误,因为空格和百分号没转义导致链接错误和报错。
因此没办法保证所有厂商的链接都正确。

@guqing
Copy link
Member Author

guqing commented Jul 29, 2023

那看是否有必要在上传到oss时对文件名中的特殊字符进行过滤或编码

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/improvement Categorizes issue or PR as related to a improvement.
Projects
None yet
Development

No branches or pull requests

2 participants