Код: Выделить всё
java.io.FileNotFoundException: Byte array resource [resource loaded from byte array] cannot be resolved to URL
at org.springframework.core.io.AbstractResource.getURL(AbstractResource.java:90) ~[spring-core-4.2.2.RELEASE.jar:4.2.2.RELEASE]
Код: Выделить всё
{"byteArray":"JVBERi0xLjQKJeL....
Код: Выделить всё
@Api("products")
@RestController
@RequestMapping("/v1/products")
public class DocumentApi extends storeApi {
@ApiOperation("GET download document")
@RequestMapping(value = "/temp", method = RequestMethod.GET)
@ResponseStatus(code = HttpStatus.OK)
public ResponseEntity downloadDocument(
@RequestParam(value = "id", required = true) Long idInscription) throws IOException {
String signedFilePAth = "C:/APPLIS/signedTemp/5982312957957647037_signed.pdf"
return ResponseEntity
.ok()
.contentLength(contentLength)
.contentType(
MediaType.parseMediaType("application/pdf"))
.body(new
ByteArrayResource(Files.readAllBytes(Paths.get(signedFilePAth))));
}
}
protected MappingJackson2HttpMessageConverter jacksonMessageConverter() {
MappingJackson2HttpMessageConverter messageConverter = new MappingJackson2HttpMessageConverter();
ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
// Registering Hibernate4Module to support lazy objects
mapper.registerModule(new Hibernate4Module());
messageConverter.setObjectMapper(mapper);
return messageConverter;
}
public ByteArrayHttpMessageConverter byteArrayHttpMessageConverter() {
ByteArrayHttpMessageConverter arrayHttpMessageConverter = new ByteArrayHttpMessageConverter();
arrayHttpMessageConverter.setSupportedMediaTypes(getSupportedMediaTypes());
return arrayHttpMessageConverter;
}
private List getSupportedMediaTypes() {
List list = new ArrayList();
list.add(MediaType.APPLICATION_OCTET_STREAM);
list.add(MediaType.parseMediaType("application/pdf"));
return list;
}
@Override
public void configureMessageConverters(List
Подробнее здесь: https://stackoverflow.com/questions/499 ... r-response
Мобильная версия