All URIs are relative to https://openapi.alipay.com
Method | HTTP request | Description |
---|---|---|
upload | POST /v3/alipay/open/file/upload | 支付宝文件上传接口 |
AlipayOpenFileUploadResponseModel upload(returnUrl, notifyUrl, data, fileContent)
支付宝文件上传接口
支付宝通用文件上传接口,支付宝开发者可以调用此接口上传文件,文件可以提供给其他业务使用,例如:上传素材(视频/图片),素材可以供给到生活号+/小程序等其他开放应用后正式发布。 该接口支持使用支付宝SDK和HTTP POST请求,两种方式示例如下: 1. 使用支付宝SDK时,可以直接使用FileItem上传,代码片段参考下文 2. 使用直接使用http协议时,需要忽略file_content参数,文件放入表单中,其余参数放入URL中,其中将参数(不包括文件和file_content)按<a href="https://opendocs.alipay.com/common/02kf5q#%E8%87%AA%E8%A1%8C%E5%AE%9E%E7%8E%B0%E7%AD%BE%E5%90%8D\">自行实现签名</a>文档实现,示例: curl --request POST 'http://openapi.alipay.com/gateway.do?charset=GBK&biz_content=%7B%22biz_code%22%3A%22content_creation%22%2C%22extra_parameters%22%3A%7B%22extern_upload%22%3A%22youku%22%2C%22alipay_user_id%22%3A%22xxxx%22%7D%7D&method=alipay.open.file.upload&format=json&sign=xxx&app_id=2014060600164699&version=1.0&sign_type=RSA2&timestamp=xxx' --form 'file=@"xx.mp4"'
// Import classes:
import com.alipay.v3.ApiClient;
import com.alipay.v3.ApiException;
import com.alipay.v3.Configuration;
import com.alipay.v3.models.*;
import com.alipay.v3.api.AlipayOpenFileApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://openapi.alipay.com");
AlipayOpenFileApi apiInstance = new AlipayOpenFileApi(defaultClient);
String returnUrl = "returnUrl_example"; // String | 页面跳转地址
String notifyUrl = "notifyUrl_example"; // String | 通知地址
AlipayOpenFileUploadModel data = new AlipayOpenFileUploadModel(); // AlipayOpenFileUploadModel |
File fileContent = new File("/path/to/file"); // File |
try {
AlipayOpenFileUploadResponseModel result = apiInstance.upload(returnUrl, notifyUrl, data, fileContent);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling AlipayOpenFileApi#upload");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
returnUrl | String | 页面跳转地址 | [optional] |
notifyUrl | String | 通知地址 | [optional] |
data | AlipayOpenFileUploadModel | [optional] | |
fileContent | File | [optional] |
AlipayOpenFileUploadResponseModel
No authorization required
- Content-Type: multipart/form-data
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | common response | - |
0 | 请求失败 | - |