git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-transfer/uri-resolver@173724 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
29da3a8dec
commit
da0e2e6e5e
8
pom.xml
8
pom.xml
|
@ -1,4 +1,5 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
|
@ -91,6 +92,11 @@
|
|||
<artifactId>authorization-client</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>storagehub-client-library</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
|
||||
<!-- jersey -->
|
||||
<dependency>
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
package org.gcube.datatransfer.resolver.services;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import org.gcube.common.storagehub.client.StreamDescriptor;
|
||||
import org.gcube.common.storagehub.client.dsl.StorageHubClient;
|
||||
|
||||
@Path("shub/{id}")
|
||||
public class StorageHub {
|
||||
|
||||
@RequestScoped
|
||||
@PathParam("id")
|
||||
String id;
|
||||
|
||||
@GET
|
||||
@Path("")
|
||||
public Response download() {
|
||||
StorageHubClient shc = new StorageHubClient();
|
||||
StreamDescriptor descriptor = shc.open(id).asFile().download();
|
||||
|
||||
return Response
|
||||
.ok(descriptor.getStream())
|
||||
.header("content-disposition","attachment; filename = \""+descriptor.getFileName()+"\"").build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{version}")
|
||||
public Response downloadVersion(@PathParam("version") String version) {
|
||||
StorageHubClient shc = new StorageHubClient();
|
||||
StreamDescriptor descriptor = shc.open(id).asFile().downloadSpecificVersion(version);
|
||||
return Response
|
||||
.ok(descriptor.getStream())
|
||||
.header("content-disposition","attachment; filename = \""+descriptor.getFileName()+"\"").build();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue