moved to 2.0
This commit is contained in:
parent
ceb01cf16f
commit
b75672f081
|
@ -22,7 +22,6 @@
|
||||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
|
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||||
|
|
4
pom.xml
4
pom.xml
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
<groupId>org.gcube.common</groupId>
|
<groupId>org.gcube.common</groupId>
|
||||||
<artifactId>storagehub-client-library</artifactId>
|
<artifactId>storagehub-client-library</artifactId>
|
||||||
<version>1.3.0-SNAPSHOT</version>
|
<version>2.0.0-SNAPSHOT</version>
|
||||||
<name>storagehub-client-library</name>
|
<name>storagehub-client-library</name>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
|
@ -51,7 +51,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.common</groupId>
|
<groupId>org.gcube.common</groupId>
|
||||||
<artifactId>storagehub-model</artifactId>
|
<artifactId>storagehub-model</artifactId>
|
||||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package org.gcube.common.storagehub.client.dsl;
|
package org.gcube.common.storagehub.client.dsl;
|
||||||
|
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
|
||||||
import org.gcube.common.scope.impl.ScopeBean;
|
import org.gcube.common.scope.impl.ScopeBean;
|
||||||
import org.gcube.common.scope.impl.ScopeBean.Type;
|
import org.gcube.common.scope.impl.ScopeBean.Type;
|
||||||
import org.gcube.common.storagehub.client.proxies.ItemManagerClient;
|
import org.gcube.common.storagehub.client.proxies.ItemManagerClient;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.gcube.common.storagehub.client.plugins;
|
package org.gcube.common.storagehub.client.plugins;
|
||||||
|
|
||||||
|
|
||||||
import javax.xml.transform.dom.DOMResult;
|
import javax.xml.transform.dom.DOMResult;
|
||||||
import javax.xml.ws.EndpointReference;
|
import javax.xml.ws.EndpointReference;
|
||||||
|
|
||||||
|
@ -17,7 +18,7 @@ import org.glassfish.jersey.media.multipart.MultiPartFeature;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
|
|
||||||
public class ItemManagerPlugin extends AbstractPlugin<GXWebTargetAdapterRequest, ItemManagerClient> {
|
public class ItemManagerPlugin extends AbstractPlugin<GXWebTargetAdapterRequest, ItemManagerClient> {
|
||||||
|
|
||||||
public ItemManagerPlugin() {
|
public ItemManagerPlugin() {
|
||||||
super("storagehub/workspace");
|
super("storagehub/workspace");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package org.gcube.common.storagehub.client.proxies;
|
package org.gcube.common.storagehub.client.proxies;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -34,10 +36,11 @@ import org.gcube.common.storagehub.model.service.ItemWrapper;
|
||||||
import org.gcube.common.storagehub.model.service.Version;
|
import org.gcube.common.storagehub.model.service.Version;
|
||||||
import org.gcube.common.storagehub.model.service.VersionList;
|
import org.gcube.common.storagehub.model.service.VersionList;
|
||||||
import org.gcube.common.storagehub.model.types.ACLList;
|
import org.gcube.common.storagehub.model.types.ACLList;
|
||||||
import org.glassfish.jersey.client.ClientProperties;
|
import org.glassfish.jersey.media.multipart.BodyPart;
|
||||||
import org.glassfish.jersey.media.multipart.FormDataBodyPart;
|
import org.glassfish.jersey.media.multipart.ContentDisposition;
|
||||||
import org.glassfish.jersey.media.multipart.FormDataMultiPart;
|
import org.glassfish.jersey.media.multipart.FormDataMultiPart;
|
||||||
import org.glassfish.jersey.media.multipart.MultiPartFeature;
|
import org.glassfish.jersey.media.multipart.MultiPartFeature;
|
||||||
|
import org.glassfish.jersey.media.multipart.file.FileDataBodyPart;
|
||||||
import org.glassfish.jersey.media.multipart.file.StreamDataBodyPart;
|
import org.glassfish.jersey.media.multipart.file.StreamDataBodyPart;
|
||||||
|
|
||||||
public class DefaultItemManager implements ItemManagerClient {
|
public class DefaultItemManager implements ItemManagerClient {
|
||||||
|
@ -621,9 +624,14 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
throw new RuntimeException(e1);
|
throw new RuntimeException(e1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String uploadFile(InputStream stream, String parentId, String fileName, String description) throws StorageHubException {
|
public String uploadFile(InputStream stream, String parentId, String fileName, String description) throws StorageHubException {
|
||||||
|
return this.uploadFile(stream, parentId, fileName, description, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String uploadFile(InputStream stream, String parentId, String fileName, String description, long contentLength) throws StorageHubException {
|
||||||
Call<GXWebTargetAdapterRequest, String> call = new Call<GXWebTargetAdapterRequest, String>() {
|
Call<GXWebTargetAdapterRequest, String> call = new Call<GXWebTargetAdapterRequest, String>() {
|
||||||
@Override
|
@Override
|
||||||
public String call(GXWebTargetAdapterRequest manager) throws Exception {
|
public String call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||||
|
@ -641,11 +649,18 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
multipart.field("name", fileName);
|
multipart.field("name", fileName);
|
||||||
multipart.field("description", description);
|
multipart.field("description", description);
|
||||||
|
|
||||||
|
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);
|
||||||
|
fdp.getHeaders().put("Content-Disposition",Arrays.asList(contentDisposition.toString()));
|
||||||
|
|
||||||
StreamDataBodyPart fdp = new StreamDataBodyPart("file", stream);
|
|
||||||
multipart.bodyPart(fdp);
|
multipart.bodyPart(fdp);
|
||||||
|
|
||||||
|
|
||||||
Entity<FormDataMultiPart> entity = Entity.entity(multipart, MediaType.MULTIPART_FORM_DATA);
|
Entity<FormDataMultiPart> entity = Entity.entity(multipart, MediaType.MULTIPART_FORM_DATA);
|
||||||
|
|
||||||
response = myManager.post(entity);
|
response = myManager.post(entity);
|
||||||
|
@ -668,30 +683,32 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
throw new RuntimeException(e1);
|
throw new RuntimeException(e1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
@Override
|
@Override
|
||||||
public String uploadFile(InputStream stream, String parentId, String fileName, String description) throws StorageHubException {
|
public String uploadFile(File file, String parentId, String fileName, String description) throws StorageHubException {
|
||||||
Call<GXWebTargetAdapterRequest, String> call = new Call<GXWebTargetAdapterRequest, String>() {
|
Call<GXWebTargetAdapterRequest, String> call = new Call<GXWebTargetAdapterRequest, String>() {
|
||||||
@Override
|
@Override
|
||||||
public String call(GXWebTargetAdapterRequest manager) throws Exception {
|
public String call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||||
Objects.requireNonNull(stream, "stream cannot be null");
|
Objects.requireNonNull(file, "file cannot be null");
|
||||||
Objects.requireNonNull(parentId, "parentId cannot be null");
|
Objects.requireNonNull(parentId, "parentId cannot be null");
|
||||||
Objects.requireNonNull(fileName, "parentId cannot be null");
|
Objects.requireNonNull(fileName, "parentId cannot be null");
|
||||||
Objects.requireNonNull(description, "parentId cannot be null");
|
Objects.requireNonNull(description, "parentId cannot be null");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GXWebTargetAdapterRequest myManager = manager.register(MultiPartFeature.class).path(parentId)
|
GXWebTargetAdapterRequest myManager = manager.register(MultiPartFeature.class).path(parentId)
|
||||||
.path("create").path("FILE");
|
.path("create").path("FILE");
|
||||||
|
|
||||||
GXInboundResponse response =null;
|
GXInboundResponse response =null;
|
||||||
Entity<InputStream> entity = Entity.entity(stream, MediaType.APPLICATION_OCTET_STREAM_TYPE);
|
FormDataMultiPart multipart = new FormDataMultiPart();
|
||||||
|
|
||||||
|
multipart.field("name", fileName);
|
||||||
|
multipart.field("description", description);
|
||||||
|
|
||||||
|
BodyPart fdp = new FileDataBodyPart("file", file);
|
||||||
|
|
||||||
|
multipart.bodyPart(fdp);
|
||||||
|
|
||||||
|
Entity<FormDataMultiPart> entity = Entity.entity(multipart, MediaType.MULTIPART_FORM_DATA);
|
||||||
|
|
||||||
Map<String, Object[]> params = new HashMap<>();
|
|
||||||
|
|
||||||
params.put("name", new Object[] {fileName});
|
|
||||||
params.put("description", new Object[] {description});
|
|
||||||
|
|
||||||
response = myManager.post(entity);
|
response = myManager.post(entity);
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
|
@ -711,7 +728,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
}catch(Exception e1) {
|
}catch(Exception e1) {
|
||||||
throw new RuntimeException(e1);
|
throw new RuntimeException(e1);
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String uploadFile(URI uri, String parentId, String fileName, String description) throws StorageHubException {
|
public String uploadFile(URI uri, String parentId, String fileName, String description) throws StorageHubException {
|
||||||
|
@ -754,10 +771,9 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String uploadArchive(InputStream stream, String parentId, String extractionFolderName) throws StorageHubException {
|
public String uploadArchive(InputStream stream, String parentId, String extractionFolderName, long contentLength)
|
||||||
|
throws StorageHubException {
|
||||||
Call<GXWebTargetAdapterRequest, String> call = new Call<GXWebTargetAdapterRequest, String>() {
|
Call<GXWebTargetAdapterRequest, String> call = new Call<GXWebTargetAdapterRequest, String>() {
|
||||||
@Override
|
@Override
|
||||||
public String call(GXWebTargetAdapterRequest manager) throws Exception {
|
public String call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||||
|
@ -771,7 +787,10 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
FormDataMultiPart multipart = new FormDataMultiPart();
|
FormDataMultiPart multipart = new FormDataMultiPart();
|
||||||
multipart.field("parentFolderName", extractionFolderName);
|
multipart.field("parentFolderName", extractionFolderName);
|
||||||
multipart.field("file", stream, MediaType.APPLICATION_OCTET_STREAM_TYPE);
|
multipart.field("file", stream, MediaType.APPLICATION_OCTET_STREAM_TYPE);
|
||||||
|
|
||||||
|
if (contentLength >0)
|
||||||
|
myManager = myManager.header("Content-Length", contentLength);
|
||||||
|
|
||||||
GXInboundResponse response = myManager.post(Entity.entity(multipart, MediaType.MULTIPART_FORM_DATA_TYPE));
|
GXInboundResponse response = myManager.post(Entity.entity(multipart, MediaType.MULTIPART_FORM_DATA_TYPE));
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
|
@ -793,6 +812,11 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
throw new RuntimeException(e1);
|
throw new RuntimeException(e1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String uploadArchive(InputStream stream, String parentId, String extractionFolderName) throws StorageHubException {
|
||||||
|
return this.uploadArchive(stream, parentId, extractionFolderName, 0);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@ -1488,4 +1512,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
}
|
}
|
||||||
return new StreamDescriptor(stream, fileName, contentType, contentLenght);
|
return new StreamDescriptor(stream, fileName, contentType, contentLenght);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.gcube.common.storagehub.client.proxies;
|
package org.gcube.common.storagehub.client.proxies;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
@ -42,6 +43,10 @@ public interface ItemManagerClient {
|
||||||
StreamDescriptor download(String id, String... excludeNodes) throws StorageHubException;
|
StreamDescriptor download(String id, String... excludeNodes) throws StorageHubException;
|
||||||
|
|
||||||
String uploadFile(InputStream stream, String parentId, String fileName, String description) throws StorageHubException;
|
String uploadFile(InputStream stream, String parentId, String fileName, String description) throws StorageHubException;
|
||||||
|
|
||||||
|
String uploadFile(InputStream stream, String parentId, String fileName, String description, long size) throws StorageHubException;
|
||||||
|
|
||||||
|
String uploadFile(File file, String parentId, String fileName, String descriptionh) throws StorageHubException;
|
||||||
|
|
||||||
String uploadFile(URI uri, String parentId, String fileName, String description) throws StorageHubException;
|
String uploadFile(URI uri, String parentId, String fileName, String description) throws StorageHubException;
|
||||||
|
|
||||||
|
@ -74,6 +79,8 @@ public interface ItemManagerClient {
|
||||||
String copy(String id, String destinationFolderId, String newFilename) throws StorageHubException;
|
String copy(String id, String destinationFolderId, String newFilename) throws StorageHubException;
|
||||||
|
|
||||||
String uploadArchive(InputStream stream, String parentId, String extractionFolderName) throws StorageHubException;
|
String uploadArchive(InputStream stream, String parentId, String extractionFolderName) throws StorageHubException;
|
||||||
|
|
||||||
|
String uploadArchive(InputStream stream, String parentId, String extractionFolderName, long contentLength) throws StorageHubException;
|
||||||
|
|
||||||
String unshareFolder(String id, Set<String> users) throws StorageHubException;
|
String unshareFolder(String id, Set<String> users) throws StorageHubException;
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,6 @@ import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
@ -14,7 +12,6 @@ import java.util.Arrays;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
@ -42,9 +39,9 @@ import org.junit.Test;
|
||||||
|
|
||||||
public class Items {
|
public class Items {
|
||||||
|
|
||||||
private static final String propFile = "C:\\Users\\tilli\\Documents\\eclipse\\tokens.properties";
|
private static final String propFile = "/home/lucio/tokens.properties";
|
||||||
|
|
||||||
private static final String tokens = "dev-root";
|
private static final String tokens = "prod-root";
|
||||||
//private static final String tokens = "prod-root";
|
//private static final String tokens = "prod-root";
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
|
@ -159,7 +156,12 @@ public class Items {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getItem() throws Exception{
|
||||||
|
StorageHubClient shc = new StorageHubClient();
|
||||||
|
String owner = shc.open("fb838c64-0924-48b4-9b45-de9be39ba860").asItem().get().getOwner();
|
||||||
|
System.out.println("owner is "+owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -4,9 +4,7 @@ import java.io.BufferedInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -17,14 +15,12 @@ import java.util.Properties;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import javax.ws.rs.WebApplicationException;
|
|
||||||
import javax.ws.rs.client.Client;
|
import javax.ws.rs.client.Client;
|
||||||
import javax.ws.rs.client.ClientBuilder;
|
import javax.ws.rs.client.ClientBuilder;
|
||||||
import javax.ws.rs.client.Entity;
|
import javax.ws.rs.client.Entity;
|
||||||
import javax.ws.rs.client.WebTarget;
|
import javax.ws.rs.client.WebTarget;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
import javax.ws.rs.core.StreamingOutput;
|
|
||||||
|
|
||||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
@ -58,7 +54,7 @@ public class TestCall {
|
||||||
|
|
||||||
private static Logger log = LoggerFactory.getLogger(TestCall.class);
|
private static Logger log = LoggerFactory.getLogger(TestCall.class);
|
||||||
|
|
||||||
private static final String propFile = "C:\\Users\\tilli\\Documents\\eclipse\\tokens.properties";
|
private static final String propFile = "/home/lucio/tokens.properties";
|
||||||
|
|
||||||
private static final String tokens = "dev-root";
|
private static final String tokens = "dev-root";
|
||||||
|
|
||||||
|
@ -184,52 +180,28 @@ public class TestCall {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void uploadDirectJersey() throws Exception {
|
|
||||||
long start = System.currentTimeMillis();
|
|
||||||
Client client = ClientBuilder.newClient();
|
|
||||||
client.property(ClientProperties.REQUEST_ENTITY_PROCESSING, "CHUNKED").property(ClientProperties.CHUNKED_ENCODING_SIZE, 1024).property(ClientProperties.OUTBOUND_CONTENT_LENGTH_BUFFER, -1);
|
|
||||||
WebTarget target = client.target("https://workspace-repository.dev.d4science.org/storagehub/workspace/items/cc7513e7-fd93-4bfb-8e1b-bc9b32938c77/create/"
|
|
||||||
+ "FILE?gcube-token=b7c80297-e4ed-42ab-ab42-fdc0b8b0eabf-98187548");
|
|
||||||
|
|
||||||
target = target.queryParam("name", "test2Gb.zip").queryParam("description", "description");
|
|
||||||
|
|
||||||
|
|
||||||
File inFile = new File("C:\\Users\\tilli\\Downloads\\testup.zip");
|
|
||||||
InputStream fileInStream = new FileInputStream(inFile);
|
|
||||||
|
|
||||||
|
|
||||||
//String contentDisposition = "attachment; filename=\"" + inFile.getName() + "\"";
|
|
||||||
System.out.println("sending: " + inFile.length() + " bytes...");
|
|
||||||
System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
|
|
||||||
Response response = target
|
|
||||||
.request(MediaType.APPLICATION_OCTET_STREAM_TYPE)
|
|
||||||
//.header("Content-Disposition", contentDisposition)
|
|
||||||
//.header("Content-Length", inFile.length())
|
|
||||||
.post(Entity.entity(fileInStream, MediaType.APPLICATION_OCTET_STREAM_TYPE));
|
|
||||||
System.out.println("Response status: " + response.getStatus()+ " in "+(System.currentTimeMillis()-start));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void upload() throws Exception{
|
public void upload() throws Exception{
|
||||||
|
|
||||||
|
System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
|
||||||
final ItemManagerClient client = AbstractPlugin.item().build();
|
final ItemManagerClient client = AbstractPlugin.item().build();
|
||||||
|
File file = new File("/home/lucio/Downloads/cali4gif.gif");
|
||||||
|
System.out.println(" file length is "+file.length());
|
||||||
|
client.uploadFile(new FileInputStream(file), "e532a011-081a-4bbd-879a-f90394c40af1", "cali4gif.gif", "description", file.length());
|
||||||
|
|
||||||
URI remote = new URI("https://data.bluecloud.cineca.it/api/download/gAAAAABhaSJN8TUA71la3mKMOL9D"
|
System.out.println(" took "+(System.currentTimeMillis()-start));
|
||||||
+ "mioSBvOehbZlu54_jvscz8Zu3LXgqhr8RfJemd83QIh47z6TyMn3mD0OjpcG5g0qf9WUZCeW1J4btEqNObkaWv"
|
|
||||||
+ "pMhabvswweyFn1Jg4m5GpwCoKayvgsYYwjbjsGsQW5Hileiw==");
|
|
||||||
|
|
||||||
|
|
||||||
client.uploadFile(remote, "bc1c9525-43f7-4565-b5ea-0a0f9d7853a0", "5gb.zip", "description");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void uploadArchive() throws Exception{
|
public void uploadArchive() throws Exception{
|
||||||
final ItemManagerClient client = AbstractPlugin.item().at(new URI("http://workspace-repository1-d.d4science.org:8080/storagehub")).build();
|
final ItemManagerClient client = AbstractPlugin.item().build();
|
||||||
|
|
||||||
client.uploadArchive(new FileInputStream("/home/lucio/Downloads/filezilla.tar"), "bc1c9525-43f7-4565-b5ea-0a0f9d7853a0", "filezillaTar1");
|
client.uploadArchive(new FileInputStream("/home/lucio/Downloads/Presentazioni utili.zip"), "bc1c9525-43f7-4565-b5ea-0a0f9d7853a0", "filezillaTar1");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue