我正在尝试将文件(从 Linux 机器上的 Chrome 浏览器)上传到 Stripe 的服务器,Stripe 服务器的响应是
com.stripe.exception.InvalidRequestException: File for key file must exist.
问题是由于 C:/fakepath/file-name 来自表单提交路径 当我在上传时硬编码它的原始路径时,它有效!
我该如何解决这个问题? 谢谢。
最佳答案
该消息不是来自 Stripe 的 API,而是来自 Java 绑定(bind)本身:https://github.com/stripe/stripe-java/blob/c7d26216b09a5a5b288ef5550c59979209979bc5/src/main/java/com/stripe/net/LiveStripeResponseGetter.java#L529-L530
重用 example来自 Stripe 的 API reference :
Stripe.apiKey = "sk_test_...";
Map<String, Object> fileUploadParams = new HashMap<String, Object>();
fileUploadParams.put("purpose", dispute_evidence);
fileUploadParams.put("file", new File('/path/to/a/file.jpg'));
FileUpload fileUpload = FileUpload.create(fileUploadParams);
如果 /path/to/a/file.jpg
不存在,将导致完全相同的错误。
关于html - 上传文件以解决 Stripe 托管帐户验证问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38114330/