Skip to content

Commit

Permalink
#23 added return value, hash of uploaded file, to uploadFile
Browse files Browse the repository at this point in the history
  • Loading branch information
dilshat committed Oct 20, 2017
1 parent 23bbff6 commit fdbef0f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/main/java/io/subutai/client/api/HubClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,10 @@ public String getCdnPrefix()
*
* @param filename full path to file
* @param version optional version of file
*
* @return hash of uploaded file
*/
void uploadFile( String filename, String version );
String uploadFile( String filename, String version );

/**
* Creates environment creation request object that should be populated further by calling party.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -802,9 +802,9 @@ public List<Template> getTemplates()
}


public void uploadFile( String filename, String version )
public String uploadFile( String filename, String version )
{
kurjunClient.uploadFile( filename, version, getKurjunToken() );
return kurjunClient.uploadFile( filename, version, getKurjunToken() );
}


Expand Down
4 changes: 3 additions & 1 deletion src/main/java/io/subutai/client/impl/KurjunClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ List<Template> getTemplates( String token )
}


void uploadFile( final String filename, final String version, final String kurjunToken )
String uploadFile( final String filename, final String version, final String kurjunToken )
{
HttpPost post = new HttpPost( String.format( "%s/raw/upload", getKurjunBaseUrl() ) );
CloseableHttpClient client = HttpClients.createDefault();
Expand All @@ -83,6 +83,8 @@ void uploadFile( final String filename, final String version, final String kurju
CloseableHttpResponse response = execute( client, post );

checkHttpStatus( response, HttpStatus.SC_OK, "upload file" );

return readContent( response );
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class HubClientImplementationTest
+ "/IX180yGqgkpjdX08MIkmANhbXDmSFh6T4lUzqGGoC7lerePwkA2yJWlsP+7JKk9oDSaYJ3lkfvKZnz8ZG7JS1jg"
+ "+sRiTsYYfyANHBJ8sDAK+eNDDms1oorrxk704r8oeNuRaE4BNKhVO4wpRJHEo4/uztLB0jkvG5OUFea5E0jCk"
+ "+tUK4R7kJBecYQGkJj4ILt/cAGrY0sg8Ol+WBOq4ex3zCF1zJrdJCxW4t2NUyNfCxW7kV2uUhbWNuj+n"
+
+
"/I5a8CDrMJsJLqdgC3EQ17uRy41GHbTwBQs0q2gwfBpefHFXokWwxu06hk0jfwFHWm9xRT79a56hr101Fy4uNjzzVtrWDS4end9VC7bt7Xf/kDxx7FB9DW1wfaYMcCp6YD5O8ENpl35gK35ZXtT5BP2GBoxHGlPdF4PObMCNi5ATtO/gLD8kW1LutO2ldsaY4sHm/JG55UNrpQCpIYe6QfkHsO+fX9/WmjP+iTDdHs1untgurvk5KdhtQxecTvTk3M/ewzHZbEbzYJYzFOsy5f6FQ8U/ckw8PejBzGDUiMGTJXl+GjV9VV3BmkKKeqD5uKu+gta5dynbdfU4r7heAV6oxan2x/rg9iHpOklIRtu2chJYJUq7lQ== [email protected]";
private static final long USER_ID = 164;
private static final String NEW_PEER_NAME = "New Peer-Name";
Expand Down Expand Up @@ -978,9 +978,9 @@ public void testRealGetTemplates() throws Exception
public void testRealUploadFile() throws Exception
{
hubClient = ( HubClientImplementation ) HubClients
.getClient( HubClient.HubEnv.PROD, "C:\\Users\\saltanat\\Downloads\\test.d_all.asc", "" );
.getClient( HubClient.HubEnv.PROD, "C:\\Users\\Dilshat\\Desktop\\test.d_all.asc", "" );

hubClient.uploadFile( "C:\\Users\\saltanat\\Desktop\\test-file.txt", "1.2.3" );
System.out.println( hubClient.uploadFile( "C:\\Users\\Dilshat\\Desktop\\test-file.txt", "1.2.3" ) );
}


Expand Down

0 comments on commit fdbef0f

Please sign in to comment.