Skip to content

Commit 9b1dc35

Browse files
author
huanglh
committed
上传文件接口新增ttl字段
1 parent ccef34d commit 9b1dc35

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<groupId>cn.jpush.api</groupId>
55
<artifactId>jpush-client</artifactId>
6-
<version>3.6.0</version>
6+
<version>3.6.1</version>
77
<packaging>jar</packaging>
88
<url>https://github.com/jpush/jpush-api-java-client</url>
99
<name>JPush API Java Client</name>

src/main/java/cn/jpush/api/file/FileClient.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,28 @@ public FileClient(String masterSecret, String appKey, HttpProxy proxy, ClientCon
4646
this._httpClient = new NativeHttpClient(authCode, proxy, conf);
4747
}
4848

49-
public FileUploadResult uploadFile(FileType type, String filename)
49+
public FileUploadResult uploadFile(FileType type, String filename, Integer ttl)
5050
throws APIConnectionException, APIRequestException {
5151
Preconditions.checkArgument(type != null, "type should not be null");
5252
Preconditions.checkArgument(StringUtils.isNotEmpty(filename), "filename should not be null");
53+
Preconditions.checkArgument(ttl >= 1 && ttl <= 720,"TTL is not in the range of 1 to 720");
5354
NativeHttpClient client = (NativeHttpClient) _httpClient;
5455
String typeStr = type.value();
5556
String url = _baseUrl + _filesPath + "/" + typeStr;
5657
Map<String, String> fileMap = new HashMap<String,String>();
5758
fileMap.put("filename", filename);
59+
fileMap.put("ttl",String.valueOf(ttl));
5860
String response = client.formUploadByPost(url, null, fileMap, null);
5961
LOG.info("uploadFile:{}", response);
6062
return _gson.fromJson(response,
6163
new TypeToken<FileUploadResult>() {
6264
}.getType());
6365
}
6466

67+
public FileUploadResult uploadFile(FileType type, String filename) throws APIConnectionException, APIRequestException {
68+
return uploadFile(type,filename,720);
69+
}
70+
6571
public FileModelPage queryEffectFiles() throws APIConnectionException, APIRequestException {
6672
String url = _baseUrl + _filesPath + "/";
6773
ResponseWrapper response = _httpClient.sendGet(url);

0 commit comments

Comments
 (0)