i normally do this with domino-rest, i use a custom reader, e.g for pdf :
public class PDFReader implements ResponseReader<Blob> {
@Override
public Blob read(Response response) {
JsResponse jsResponse = (JsResponse) response;
Uint8Array buffer = new Uint8Array(jsResponse.getResponseArrayBuffer());
BlobPropertyBag options = BlobPropertyBag.create();
options.setType("application/pdf, application/octet-stream");
return new Blob(new Blob.ConstructorBlobPartsArrayUnionType[]{
Blob.ConstructorBlobPartsArrayUnionType.of(buffer)
}, options);
}
}
and the service is defined like this
@Path("{uuid}/report/{type}")
@GET
@Produces(MediaType.APPLICATION_OCTET_STREAM)
@Reader(PDFReader.class)
Blob printReport(@PathParam("uuid") String uuid, @PathParam("type") String type);
and i call it using
ReportServiceFactory.INSTANCE
.printReport(message.getUuid(), "PDF")
.setResponseType("arraybuffer")
.onSuccess(onEntriesLoaded::accept)
.onFailed(failedResponseBean -> {
LOGGER.error("failed to download entries " + failedResponseBean);
})
.send();
For now I found out such solution:
Request request = new Request(DominoRestConfig.getInstance().getDefaultServiceRoot() + API_ROOT + SupportPackageRestResource.URL + "/" + packageName);
request.headers.append(AUTHORIZATION, context.getAuthorizationHeader());
DomGlobal.window.fetch(request2);
but not tested yet
@GET
@Path("{fileName}")
@Produces("application/zip")
@JWTTokenNeeded
public Response get(@PathParam("fileName") String fileName) {
return Response.ok(
new File(Paths.get(System.getProperty("java.io.tmpdir"), fileName).toString() + ".zip"),
MediaType.APPLICATION_OCTET_STREAM)
.header("Content-Disposition", "attachment; filename=\"" + fileName + ".zip\"")
.build();
}
.setReader
import java.sql.Blob;
Hi all: I'm trying to build my project this morning and suddenly the elemento-core jar we've been depending on is suddenly missing from the main Maven repository.
[ivy:resolve] :: problems summary ::
[ivy:resolve] :::: WARNINGS
[ivy:resolve] [NOT FOUND ] org.jboss.gwt.elemento#elemento-core;0.8.2-gwt2!elemento-core.gwt-lib (387ms)
[ivy:resolve] ==== ibiblio: tried
[ivy:resolve] https://repo1.maven.org/maven2/org/jboss/gwt/elemento/elemento-core/0.8.2-gwt2/elemento-core-0.8.2-gwt2.gwt-lib
Did something happen to the older artifacts?
.jar
, not a .sources
)