removed double call for upload file
This commit is contained in:
parent
28e4e9eb56
commit
18d2fb9287
|
@ -663,22 +663,6 @@ public class DefaultItemManager extends DefaultManagerClient implements ItemMana
|
||||||
|
|
||||||
response = myManager.queryParams(initQueryParameters()).post(Entity.entity(multipart, multipart.getMediaType()));
|
response = myManager.queryParams(initQueryParameters()).post(Entity.entity(multipart, multipart.getMediaType()));
|
||||||
|
|
||||||
|
|
||||||
ContentDisposition contentDisposition;
|
|
||||||
if (contentLength>0)
|
|
||||||
contentDisposition = ContentDisposition.type("attachment").fileName(fileName).size(contentLength).build();
|
|
||||||
else
|
|
||||||
contentDisposition = ContentDisposition.type("attachment").fileName(fileName).build();
|
|
||||||
|
|
||||||
|
|
||||||
BodyPart fdp = new StreamDataBodyPart("file", stream);
|
|
||||||
|
|
||||||
multipart.bodyPart(fdp);
|
|
||||||
|
|
||||||
Entity<FormDataMultiPart> entity = Entity.entity(multipart, MediaType.MULTIPART_FORM_DATA);
|
|
||||||
|
|
||||||
response = myManager.queryParams(initQueryParameters()).header("Content-Disposition",Arrays.asList(contentDisposition.toString())).post(entity);
|
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
if (response.hasException()) {
|
if (response.hasException()) {
|
||||||
throw response.getException();
|
throw response.getException();
|
||||||
|
|
|
@ -104,7 +104,7 @@ public class Items {
|
||||||
File file = new File(vresFile);
|
File file = new File(vresFile);
|
||||||
|
|
||||||
try ( InputStream fileIS = new FileInputStream(file)){
|
try ( InputStream fileIS = new FileInputStream(file)){
|
||||||
shc.getWSRoot().uploadFile(fileIS, "stampa_crossover_retro.pdf", "description");
|
shc.getWSRoot().uploadFile(fileIS, "stampa_crossover_retro.pdf", "description");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -134,23 +134,30 @@ public class Items {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|
||||||
IntStream.range(1, 100).forEach( i-> {
|
IntStream.range(1, 300).forEach( i-> {
|
||||||
try {
|
try {
|
||||||
StorageHubClient shc = new StorageHubClient();
|
StorageHubClient shc = new StorageHubClient();
|
||||||
FolderContainer vre = shc.openVREFolder().openByRelativePath("testLucio").asFolder();
|
FolderContainer vre = shc.openVREFolder().openByRelativePath("testLucio").asFolder();
|
||||||
FolderContainer fc = vre.newFolder("folder"+i, "");
|
FolderContainer fc = vre.newFolder("folder"+i, "");
|
||||||
IntStream.range(1, 3).forEach(k -> {
|
for (int t =1 ; t<10; t++) {
|
||||||
String vresFile = "/home/lucio/Scaricati/NLP-Hub-Algorithms.pptx";
|
StorageHubClient shc1 = new StorageHubClient();
|
||||||
|
FolderContainer sub = shc1.open(fc.getId()).asFolder();
|
||||||
|
FolderContainer fcsub2 = sub.newFolder("folder"+i+"-"+t, "");
|
||||||
|
for (int k=0;k<3;k++) {
|
||||||
|
String vresFile = "/home/lucio/Downloads/GNA_foto_Cuma Necropoli mediana_4B.jpg";
|
||||||
|
|
||||||
File file = new File(vresFile);
|
StorageHubClient shc2 = new StorageHubClient();
|
||||||
|
FolderContainer sub2 = shc2.open(fcsub2.getId()).asFolder();
|
||||||
|
|
||||||
try ( InputStream fileIS = new FileInputStream(file)){
|
File file = new File(vresFile);
|
||||||
fc.uploadFile(fileIS, "file"+k, "description");
|
|
||||||
} catch (Exception e) {
|
try ( InputStream fileIS = new FileInputStream(file)){
|
||||||
e.printStackTrace();
|
sub2.uploadFile(fileIS, "file"+k, "description");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
} catch (StorageHubException e) {
|
} catch (StorageHubException e) {
|
||||||
System.out.println("error creating stressTest"+i);
|
System.out.println("error creating stressTest"+i);
|
||||||
}
|
}
|
||||||
|
@ -243,7 +250,7 @@ public class Items {
|
||||||
|
|
||||||
File inFile = new File("/home/lucio/Downloads/scimmia braccia aperte.mp4");
|
File inFile = new File("/home/lucio/Downloads/scimmia braccia aperte.mp4");
|
||||||
try(InputStream is = new FileInputStream(inFile)){
|
try(InputStream is = new FileInputStream(inFile)){
|
||||||
myRoot.uploadFile(is, "scimmia braccia aperte.mp4", "file");
|
myRoot.uploadFile(is, "scimmia braccia aperte.mp4", "file");
|
||||||
|
|
||||||
}
|
}
|
||||||
System.out.println("Response in "+(System.currentTimeMillis()-start));
|
System.out.println("Response in "+(System.currentTimeMillis()-start));
|
||||||
|
|
Loading…
Reference in New Issue