added Content-Disposition HTTP header for better support of download file's name
This commit is contained in:
@@ -29,9 +29,7 @@ import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.io.*;
|
||||
import java.net.URI;
|
||||
import java.nio.file.Files;
|
||||
import java.util.List;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -284,6 +282,22 @@ public class PacmanWebService
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/doYouWantAny")
|
||||
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
||||
public Response doYouWantAny(List<String> filenames)
|
||||
{
|
||||
Set<String> result = new HashSet<>(filenames);
|
||||
if(!result.isEmpty())
|
||||
{
|
||||
TypedQuery<String> query = em.createQuery("SELECT pkg.fileName from PkgData pkg WHERE pkg.fileName in :filenames", String.class);
|
||||
query.setParameter("filenames", filenames);
|
||||
Set<String> toBeRemoved = new HashSet(query.getResultList());
|
||||
result.removeAll(toBeRemoved);
|
||||
}
|
||||
return Response.ok(result).build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/upload")
|
||||
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
|
||||
@@ -466,7 +480,7 @@ public class PacmanWebService
|
||||
}
|
||||
}
|
||||
};
|
||||
return Response.ok(stream).build();
|
||||
return Response.ok(stream).header("Content-Disposition", "attachment; filename=pkgs.tar").build();
|
||||
}
|
||||
|
||||
private Response manageQueryResult(List<PkgData> list)
|
||||
|
Reference in New Issue
Block a user