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

Upload 上传图片后的预览图不是实际上传的图片 #1030

Closed
liunian opened this issue Sep 24, 2020 · 0 comments · Fixed by #1031
Closed

Upload 上传图片后的预览图不是实际上传的图片 #1030

liunian opened this issue Sep 24, 2020 · 0 comments · Fixed by #1031

Comments

@liunian
Copy link
Contributor

liunian commented Sep 24, 2020

Describe the bug

使用 @formily/next 的 Upload 来上传图片,上传完后,组件预览的图片不是实际上传的图片。

上传的图片
image

预览的图片
image

To Reproduce

上传后返回或 format 后的结果中的 imgURL 是类似 //img.z-any.com/xx.png 的形式即可重现。

原因是,总是使用 imgURL 去匹配内置的 icon,虽然 exclude 中默认包含了图片扩展名(如 .png),但由于正则没指定匹配到最后面,所以,前面的路径,虽然在 .png 哪条规则上跳过了,但却会命中 .z 这个正则。

Expected behavior

接口有提供预览图片时,使用提供的图片而非默认图片

Additional context

return {
name: file.name,
downloadURL: file.downloadURL || file.imgURL,
...file.response,
imgURL: getImageByUrl(file.imgURL, {
exclude: ['.png', '.jpg', '.jpeg', '.gif']
})
}

{
ext: /\.(zip|rar|arj|z|gz|iso|jar|ace|tar|uue|dmg|pkg|lzh|cab)/i,
icon: '//img.alicdn.com/tfs/TB10jmfr29TBuNjy0FcXXbeiFXa-200-200.png'
},

liunian added a commit to liunian/formily that referenced this issue Sep 24, 2020
Use provided image first, if not exist, then fallback to suggested icon.
fix ext match pattern

close alibaba#1030
janryWang pushed a commit that referenced this issue Sep 25, 2020
Use provided image first, if not exist, then fallback to suggested icon.
fix ext match pattern

close #1030
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 a pull request may close this issue.

1 participant