List of usage examples for org.springframework.http MediaType MULTIPART_FORM_DATA_VALUE
String MULTIPART_FORM_DATA_VALUE
To view the source code for org.springframework.http MediaType MULTIPART_FORM_DATA_VALUE.
Click Source Link
From source file:software.uncharted.rest.ImageResource.java
@RequestMapping(value = "/histogram", method = RequestMethod.POST, consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) public ImageHistogramResponse getImageHistogram(@RequestParam("image") final MultipartFile file) throws IOException { String fileType = file.getContentType(); if (fileType.startsWith("image")) { BufferedImage image = ImageIO.read(file.getInputStream()); final String histogram = service.getHistogram(image); final String base64Str = ImageProcessing.toBase64(image); return new ImageHistogramResponse().setDataURI("data:image/png;base64," + base64Str) .setHistogram(histogram); }//from w ww . j ava2s.c o m return null; }
From source file:com.wavemaker.tools.apidocs.tools.spring.resolver.MultiPartRequestResolver.java
@Override public List<Parameter> resolveParameter(final int index, final TypeInformation typeInformation, final Annotation[] annotations, final Operation operation) { // setting consumes operation.setConsumes(Arrays.asList(MediaType.MULTIPART_FORM_DATA_VALUE)); return Collections.EMPTY_LIST; }
From source file:software.uncharted.rest.ImageSearchResource.java
@RequestMapping(value = "/file", method = RequestMethod.POST, consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) public ImageSearchResult searchByFile(@RequestParam("image") final MultipartFile file) throws IOException { long start = System.nanoTime(); String fileType = file.getContentType(); if (fileType.startsWith("image")) { BufferedImage image = ImageIO.read(file.getInputStream()); Set<Image> images = service.search(image); long duration = (System.nanoTime() - start) / 1000000L; return new ImageSearchResult().setImages(images).setDuration(duration); }// ww w .ja va2 s . co m return ImageSearchResult.empty(); }
From source file:org.jhk.pulsing.web.controller.PulseController.java
@RequestMapping(value = "/createPulse", method = RequestMethod.POST, consumes = { MediaType.MULTIPART_FORM_DATA_VALUE }) public @ResponseBody Result<Pulse> createPulse(@RequestParam Pulse pulse) { _LOGGER.debug("PulseController.createPulse: " + pulse); return pulseService.createPulse(pulse); }
From source file:org.jhk.pulsing.web.controller.UserController.java
@RequestMapping(value = "/createUser", method = RequestMethod.POST, consumes = { MediaType.MULTIPART_FORM_DATA_VALUE }) public @ResponseBody Result<User> createUser(@RequestParam User user, @RequestParam(name = "picture", required = false) MultipartFile mPicture) { _LOGGER.debug("UserController.createUser: " + user + "; " + (mPicture != null ? ("picture size is: " + mPicture.getSize()) : "picture not submitted")); if (mPicture != null) { try {/*from www.j a v a 2 s .c o m*/ ByteBuffer pBuffer = ByteBuffer.wrap(mPicture.getBytes()); Picture picture = Picture.newBuilder().build(); picture.setContent(pBuffer); picture.setName(mPicture.getOriginalFilename()); user.setPicture(picture); } catch (IOException iException) { _LOGGER.error("Could not get picture bytes", iException); } } return userService.createUser(user); }
From source file:springfox.documentation.spring.web.scanners.MediaTypeReader.java
@Override public void apply(OperationContext context) { Set<String> consumesList = toSet(context.consumes()); Set<String> producesList = toSet(context.produces()); if (handlerMethodHasFileParameter(context)) { consumesList = newHashSet(MediaType.MULTIPART_FORM_DATA_VALUE); }//from w w w .j a v a 2 s . c o m if (producesList.isEmpty()) { producesList.add(MediaType.ALL_VALUE); } if (consumesList.isEmpty()) { consumesList.add(MediaType.APPLICATION_JSON_VALUE); } context.operationBuilder().consumes(consumesList); context.operationBuilder().produces(producesList); }
From source file:org.ow2.proactive.workflow_catalog.rest.controller.WorkflowRevisionController.java
@ApiOperation(value = "Creates a new workflow revision") @ApiResponses(value = { @ApiResponse(code = 404, message = "Bucket not found"), @ApiResponse(code = 422, message = "Invalid XML workflow content supplied") }) @RequestMapping(value = "/buckets/{bucketId}/workflows/{workflowId}/revisions", consumes = { MediaType.MULTIPART_FORM_DATA_VALUE }, method = POST) @ResponseStatus(HttpStatus.CREATED)//from w ww .ja v a 2 s. c o m public WorkflowMetadata create(@PathVariable Long bucketId, @PathVariable Long workflowId, @ApiParam(value = "Layout describing the tasks position in the Workflow Revision") @RequestParam(required = false) Optional<String> layout, @RequestPart(value = "file") MultipartFile file) throws IOException { return workflowRevisionService.createWorkflowRevision(bucketId, Optional.of(workflowId), file.getBytes(), layout); }
From source file:org.jhk.pulsing.web.controller.UserController.java
@RequestMapping(value = "/validateUser", method = RequestMethod.POST, consumes = { MediaType.MULTIPART_FORM_DATA_VALUE }) public @ResponseBody Result<User> validateUser(@RequestParam String email, @RequestParam String password) { _LOGGER.debug("UserController.validateUser: " + email + ", " + password); return userService.validateUser(email, password); }
From source file:org.ow2.proactive.workflow_catalog.rest.controller.WorkflowController.java
@ApiOperation(value = "Creates a new workflow") @ApiResponses(value = { @ApiResponse(code = 404, message = "Bucket not found"), @ApiResponse(code = 422, message = "Invalid XML workflow content supplied") }) @RequestMapping(value = "/buckets/{bucketId}/workflows", consumes = { MediaType.MULTIPART_FORM_DATA_VALUE }, method = POST) @ResponseStatus(HttpStatus.CREATED)//from w ww . j a v a 2 s . c o m public WorkflowMetadataList create(@PathVariable Long bucketId, @ApiParam(value = "Layout describing the tasks position in the Workflow") @RequestParam(required = false) Optional<String> layout, @ApiParam(value = "Import workflows from ZIP when set to 'zip'.") @RequestParam(required = false) Optional<String> alt, @RequestPart(value = "file") MultipartFile file) throws IOException { if (alt.isPresent() && ZIP_EXTENSION.equals(alt.get())) { return new WorkflowMetadataList(workflowService.createWorkflows(bucketId, layout, file.getBytes())); } else { return new WorkflowMetadataList(workflowService.createWorkflow(bucketId, layout, file.getBytes())); } }
From source file:apiserver.services.cache.controllers.CacheDocumentController.java
/** * put document into cache, usable for future manipulations APIs * * @param uploadedFile uploaded file//from w w w. j a va2 s. c o m * @param tags list of metadata tags * @return cache ID */ //@ApiOperation(value = "add a document to cache", multiValueResponse = true) @RequestMapping(method = RequestMethod.POST, consumes = MediaType.MULTIPART_FORM_DATA_VALUE) public WebAsyncTask<String> addDocument( @ApiParam(name = "uploadedFile", required = true) @RequestParam(value = "uploadedFile", required = true) MultipartFile uploadedFile, @ApiParam(name = "tags", required = false) @RequestParam(required = false) String[] tags) throws InterruptedException, TimeoutException, ExecutionException { final MultipartFile _file = uploadedFile; final String[] _tags = tags; Callable<String> callable = new Callable<String>() { @Override public String call() throws Exception { UploadDocumentJob job = new UploadDocumentJob(_file); job.setTags(_tags); Future<DocumentJob> imageFuture = documentAddGateway.addDocument(job); DocumentJob payload = imageFuture.get(defaultTimeout, TimeUnit.MILLISECONDS); return payload.getDocument().getId(); } }; return new WebAsyncTask<String>(10000, callable); }