alipay/alipay-sdk-nodejs-all

alipay.open.file.upload上传超出限制

Closed this issue · 4 comments

调用alipaySdk.exec('alipay.open.file.upload', ....),没有经过nginx。

待上传文件大概150M左右,方法报错如下:
AlipayRequestError: HTTP 请求错误, status: 413

\r\n' +
'<html>\r\n' +
'<head><title>413 Request Entity Too Large</title></head>\r\n' +
'<body bgcolor="white">\r\n' +
'<h1>413 Request Entity Too Large</h1>\r\n' +
'<P>The requested resource does not allow request data with the requested method or the amount of data provided in the request exceeds the capacity limit. Sorry for the inconvenience.<br/>\r\n' +
'Please report this message and include the following information to us.<br/>\r\n' +
'Thank you very much!</p>\r\n' +
'<table>\r\n' +
'<tr>\r\n' +
'<td>URL:</td>\r\n' +
'<td>https://openapi.alipay.com:3012/gateway.do?method=alipay.open.file.upload&amp;app_id=(删除)&amp;charset=utf-8&amp;version=1.0&amp;sign_type=RSA2&amp;timestamp=2024-06-04+18%3A52%3A05&amp;sign=p3xs9ie2ipq9dGXin%2Fq6mA7Xkbq3pTG15y8C%2BmX%2FpLj2Uly5uENCsVNDE5K036829xIRLA4aa2101c6Ee9YG5xLKOqlPav15dfpEelrc3Tzotr3hQ%2FQ7S461LXaOt1VB8WcXDsEr5MqAx6hFUcTQDwE0O7NaeUpTCVVWYIWK57bOpy8BP317DKrdUVQBRSbe2XsRrw7YXrCFnw2OuJpBPaOahms9nWKxaP6oTBcwE5TsRRpb1fgdVzM2BGv0aKexw8pbzySpd8R6DZ1HbIC6MDZfJz44WO4wtcih9kI2XuFVIa9%2BYecHEGgY%2BbW3Qzt07GVH8G5ZEq%2BwLnWvtMf1Dg%3D%3D</td>\r\n' +
'</tr>\r\n' +
'<tr>\r\n' +
'<td>Server:</td>\r\n' +
'<td>spanner-internet-cz50b-26742.sa127</td>\r\n' +
'</tr>\r\n' +
'<tr>\r\n' +
'<td>Date:</td>\r\n' +
'<td>2024/06/04 18:52:11</td>\r\n' +
'</tr>\r\n' +
'</table>\r\n' +
'<hr/>Powered by Tengine/2.1.0</body>\r\n' +
'</html>\r\n

请问你上传的文件名后缀是那种类型的?

https://github.com/alipay/alipay-sdk-nodejs-all?tab=readme-ov-file#%E4%BD%BF%E7%94%A8-alipayformdata-%E8%A1%A8%E5%8D%95%E4%B8%8A%E4%BC%A0%E6%96%87%E4%BB%B6 @gwwnha 可以试试最新版本,走 curl 接口上传,我测试了一下支付宝 openapi v3 协议是不会出现这个问题的。

定位到了问题,需要 sdk 设置 content-length 在请求 header 里面。这个会在 alipay-sdk@4 版本修复。

#134 会修复此问题