This commit is contained in:
Lucio Lelii 2018-10-19 15:06:53 +00:00
parent 29da3a8dec
commit da0e2e6e5e
2 changed files with 61 additions and 16 deletions

View File

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

View File

@ -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();
}
}