alipay / alipay-sdk-nodejs-all

支付宝开放平台 Alipay SDK for Node.js
https://docs.open.alipay.com/54/103419/
Other
407 stars 64 forks source link

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

Closed gwwnha closed 4 months ago

gwwnha commented 4 months ago

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

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

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">\r\n' + '\r\n' + '413 Request Entity Too Large\r\n' + '\r\n' + '

413 Request Entity Too Large

\r\n' + '

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.
\r\n' + 'Please report this message and include the following information to us.
\r\n' + 'Thank you very much!

\r\n' + '\r\n' + '\r\n' + '\r\n' + '\r\n' + '\r\n' + '\r\n' + '\r\n' + '\r\n' + '\r\n' + '\r\n' + '\r\n' + '\r\n' + '\r\n' + '
URL: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
Server:spanner-internet-cz50b-26742.sa127
Date:2024/06/04 18:52:11
\r\n' + '
Powered by Tengine/2.1.0\r\n' + '\r\n

fengmk2 commented 4 months ago

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

fengmk2 commented 4 months ago

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 协议是不会出现这个问题的。

fengmk2 commented 4 months ago

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

fengmk2 commented 4 months ago

https://github.com/alipay/alipay-sdk-nodejs-all/pull/134 会修复此问题