@@ -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