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组件将file参数放在定制参数的最后,以支持阿里云OSS上传 #2504

Closed
casatwy opened this issue Feb 24, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@casatwy
Copy link

casatwy commented Feb 24, 2022

TuSimple/naive-ui version (版本)

2.25.5

Vue version (Vue 版本)

3.2.31

Browser and its version (浏览器及其版本)

Chrome 98.0.4758.102

System and its version (系统及其版本)

MacOS 12.2.1

Node version (Node 版本)

Reappearance link (重现链接)

https://github.com/TuSimple/naive-ui

Reappearance steps (重现步骤)

naive-ui的upload组件是一个很棒的组件,我在使用它做阿里云OSS上传的时候,发现一个问题:

The bucket POST must contain the specified 'key'. If it is specified, please check the order of the fields
截屏2022-02-24 上午10 06 32

我对此搜索了一下,找到了一个stackoverflow的答案:
https://stackoverflow.com/questions/15234496/upload-directly-to-amazon-s3-using-ajax-returning-error-bucket-post-must-contai

虽然这个答案不见得是针对阿里云OSS平台的,但它提到上传文件时附带参数的顺序会影响这次上传是否成功。具体说来就是file之后的参数,都会被平台忽略。

补充一个背景:使用阿里云OSS做服务端签名后直传的方式上传文件时(服务器签名后直传方式),这种方式需要带上我自己业务服务端提供的签名信息,我在实践中,使用upload组件的data属性带上签名信息。

结合上面OSS报的错误信息,它提到“please check the order of the fields”,我截取数据包观察发现upload组件确实把我的签名信息带上了,但是file参数排在第一位,这意味着file之后的参数都会被平台忽略,因此阿里云的OSS平台会报上述的错误。
截屏2022-02-24 上午10 14 37

因此我期望Upload组件能够在【文件上传同时附带自定参数】的场景下,将file参数放到最后。

Expected results (期望的结果)

能够在有自定义上传参数的情况下,file参数放到表单最后的位置

Actual results (实际的结果)

无法支持阿里云OSS平台的上传功能

Remarks (补充说明)

@github-actions github-actions bot added the untriaged need to sort label Feb 24, 2022
@casatwy casatwy changed the title Upload组件将file参数放在定制参数的最后,以支持阿里云OSS上传 期望Upload组件将file参数放在定制参数的最后,以支持阿里云OSS上传 Feb 24, 2022
@casatwy
Copy link
Author

casatwy commented Feb 24, 2022

补充一下我搜到的另一篇文档:https://www.jianshu.com/p/e8f1b7f2439f

文档里面也提到了file必须放在最后一个位置,否则就会触发The bucket POST must contain the specified 'key'. If it is specified, please check the order of the fields错误

同时我也搜到了官方文档:https://help.aliyun.com/document_detail/42976.html?spm=a2c4g.11186623.2.13.11cd1a210eyJOX

截屏2022-02-24 下午5 22 58

@07akioni 07akioni added bug Something isn't working and removed untriaged need to sort labels Feb 27, 2022
jaulz pushed a commit to jaulz/naive-ui that referenced this issue Mar 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants
@casatwy @07akioni and others