当前位置: 首页>>代码示例>>Java>>正文


Java MediaType.MULTIPART_FORM_DATA_VALUE属性代码示例

本文整理汇总了Java中org.springframework.http.MediaType.MULTIPART_FORM_DATA_VALUE属性的典型用法代码示例。如果您正苦于以下问题:Java MediaType.MULTIPART_FORM_DATA_VALUE属性的具体用法?Java MediaType.MULTIPART_FORM_DATA_VALUE怎么用?Java MediaType.MULTIPART_FORM_DATA_VALUE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.springframework.http.MediaType的用法示例。


在下文中一共展示了MediaType.MULTIPART_FORM_DATA_VALUE属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: requestBodyFlux

@PostMapping(value = "", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
Mono<String> requestBodyFlux(@RequestBody Flux<Part> parts) {
    return partFluxDescription(parts);
}
 
开发者ID:hantsy,项目名称:spring-reactive-sample,代码行数:4,代码来源:MultipartController.java

示例2: createFrom

@PostMapping(value = "", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@ApiOperation("Creates a list of Stored Documents by uploading a list of binary/text files.")
@ApiResponses(value = {
    @ApiResponse(code = 200, message = "Success", response = StoredDocumentHalResourceCollection.class)
})
public ResponseEntity<Object> createFrom(
        @Valid UploadDocumentsCommand uploadDocumentsCommand,
        BindingResult result) throws MethodArgumentNotValidException {

    if (result.hasErrors()) {
        throw new MethodArgumentNotValidException(uploadDocumentsCommandMethodParameter, result);
    } else {
        List<StoredDocument> storedDocuments =
                auditedStoredDocumentOperationsService.createStoredDocuments(uploadDocumentsCommand);
        return ResponseEntity
                .ok()
                .contentType(V1MediaType.V1_HAL_DOCUMENT_COLLECTION_MEDIA_TYPE)
                .body(new StoredDocumentHalResourceCollection(storedDocuments));
    }
}
 
开发者ID:hmcts,项目名称:document-management-store-app,代码行数:20,代码来源:StoredDocumentController.java

示例3: update

/**
 * @api {patch} /credentials/:name Update
 * @apiParam {String} name Credential name to update
 *
 * @apiParamExample {multipart} RSA-Multipart-Body:
 *  the same as create
 *
 * @apiGroup Credenital
 */
@PatchMapping(path = "/{name}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@WebSecurity(action = Actions.ADMIN_UPDATE)
public Credential update(@PathVariable String name,
                         @RequestParam(name = "detail") String detailJson,
                         @RequestPart(name = "android-file", required = false) MultipartFile androidFile,
                         @RequestPart(name = "p12-files", required = false) MultipartFile[] p12Files,
                         @RequestPart(name = "pp-files", required = false) MultipartFile[] ppFiles) {

    // check name is existed
    if (!credentialService.existed(name)) {
        throw new IllegalParameterException("Credential name does not existed");
    }

    CredentialDetail detail = jsonConverter.getGsonForReader().fromJson(detailJson, CredentialDetail.class);
    return createOrUpdate(name, detail, androidFile, p12Files, ppFiles);
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:25,代码来源:CredentialController.java

示例4: generateFromHtml

@APIDeprecated(
    name = "/api/v1/pdf-generator/html",
    docLink = "https://github.com/hmcts/cmc-pdf-service#standard-api",
    expiryDate = "2018-02-08",
    note = "Please use `/pdfs` instead.")
@ApiOperation("Returns a PDF file generated from provided HTML/Twig template and placeholder values")
@PostMapping(
    value = "/html",
    consumes = MediaType.MULTIPART_FORM_DATA_VALUE,
    produces = MediaType.APPLICATION_PDF_VALUE
)
public ResponseEntity<ByteArrayResource> generateFromHtml(
    @ApiParam("A HTML/Twig file. CSS should be embedded, images should be embedded using Data URI scheme")
    @RequestParam("template") MultipartFile template,
    @ApiParam("A JSON structure with values for placeholders used in template file")
    @RequestParam("placeholderValues") String placeholderValues
) {
    log.debug("Received a PDF generation request");
    byte[] pdfDocument = htmlToPdf.convert(asBytes(template), asMap(placeholderValues));
    log.debug("PDF generated");
    return ResponseEntity
        .ok()
        .contentLength(pdfDocument.length)
        .body(new ByteArrayResource(pdfDocument));
}
 
开发者ID:hmcts,项目名称:cmc-pdf-service,代码行数:25,代码来源:PDFGenerationEndpoint.java

示例5: importConversations

@ApiOperation(value = "import conversations")
@RequestMapping(value = "import", method = RequestMethod.POST, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<?> importConversations(
        AuthContext authContext,
        @RequestParam("owner") ObjectId owner,
        @RequestParam(value = "replace", defaultValue = "false", required = false) boolean replace,
        @RequestPart("file") MultipartFile file
) {

    if (authenticationService.hasAccessToClient(authContext, owner)) {
        try {
            final List<Conversation> conversations = jacksonObjectMapper.readValue(file.getInputStream(),
                    jacksonObjectMapper.getTypeFactory().constructCollectionType(List.class, Conversation.class));
            return importConversations(authContext, owner, replace, conversations);
        } catch (IOException e) {
            return ResponseEntity.unprocessableEntity().build();
        }
    } else {
        return ResponseEntity.badRequest().build();
    }
}
 
开发者ID:redlink-gmbh,项目名称:smarti,代码行数:21,代码来源:ConversationAdminWebservice.java

示例6: saveCytobands

@ResponseBody
@RequestMapping(value = "/cytobands/upload", method = RequestMethod.POST,
    consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@ApiOperation(
    value = "Handles cytobands upload pointing to a corresponded genome that has to be available in the system.",
    notes = "The following cytobands file types are supported: *.txt and *.txt.gz.<br/>" +
        "It results in a payload that provides corresponded genome ID, also a message about succeeded upload " +
        "is sent back.",
    produces = MediaType.APPLICATION_JSON_VALUE)
@ApiResponses(
    value = {@ApiResponse(code = HTTP_STATUS_OK, message = API_STATUS_DESCRIPTION)
    })
public final Result<Long> saveCytobands(@RequestParam("referenceId") final Long referenceId,
                                        @RequestParam("saveFile") final MultipartFile multipart)
    throws IOException {
    final File tmpFile = transferToTempFile(multipart);
    cytobandManager.saveCytobands(referenceId, tmpFile);
    return Result.success(referenceId, getMessage("info.cytobands.upload.done",
        multipart.getOriginalFilename()));
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:20,代码来源:CytobandController.java

示例7: uploadSingleFile

@PostMapping(value = "", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
Mono<String> uploadSingleFile(@RequestBody Mono<FilePart> part) {

    FilePart filePart = part
        .log()
        .block();

    String name = UUID.randomUUID().toString() + "-" + filePart.name();
    String contentType = filePart.headers().getContentType().toString();
    ObjectId id = this.gridFsTemplate.store(filePart.content().blockFirst().asInputStream(), name, contentType);
    
    return Mono.just(id.toString());
}
 
开发者ID:hantsy,项目名称:spring-reactive-sample,代码行数:13,代码来源:MultipartController.java

示例8: addDocumentContentVersion

@PostMapping(value = "", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@ApiOperation("Adds a Document Content Version and associates it with a given Stored Document.")
@ApiResponses(value = {
    @ApiResponse(code = 201, message = "JSON representation of a document version")
})
public ResponseEntity<Object> addDocumentContentVersion(@PathVariable UUID documentId,
                                                        @Valid UploadDocumentVersionCommand command,
                                                        BindingResult result) {
    if (result.hasErrors()) {
        throw new ValidationErrorException(result.getFieldErrors().stream()
            .map(fe -> String.format("%s - %s", fe.getField(), fe.getCode()))
            .collect(Collectors.joining(",")));
    } else {
        StoredDocument storedDocument = storedDocumentService.findOne(documentId);

        if (storedDocument == null || storedDocument.isDeleted()) {

            throw new StoredDocumentNotFoundException(documentId);

        } else {

            DocumentContentVersionHalResource resource =
                new DocumentContentVersionHalResource(
                    auditedStoredDocumentOperationsService.addDocumentVersion(storedDocument, command.getFile())
                );

            return ResponseEntity
                .created(resource.getURI())
                .contentType(V1MediaType.V1_HAL_DOCUMENT_CONTENT_VERSION_MEDIA_TYPE)
                .body(resource);
        }
    }
}
 
开发者ID:hmcts,项目名称:document-management-store-app,代码行数:33,代码来源:DocumentContentVersionController.java

示例9: addDocuments

@PostMapping(value = "/{id}/documents", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@ApiOperation("Adds a list of Stored Documents to a Folder (Stored Documents are created from uploaded Documents)")
public ResponseEntity<Object> addDocuments(@PathVariable UUID id, @RequestParam List<MultipartFile> files) {
    Folder existingFolder = folderService.findOne(id);

    if (existingFolder == null) {
        return ResponseEntity.notFound().build();
    }

    storedDocumentService.saveItemsToBucket(existingFolder, files);
    return ResponseEntity.noContent().build();
}
 
开发者ID:hmcts,项目名称:document-management-store-app,代码行数:12,代码来源:FolderController.java

示例10: post

@PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<Media> post(HttpServletRequest request) {
    try {
        String fullRequestUrl = UrlHelper.getFullRequestUrl(request);
        Media media = mediaService.createMedia(fullRequestUrl, request.getPart("file").getInputStream());
        return ResponseEntity.created(URI.create(fullRequestUrl + "/" + media.getId())).body(media);
    } catch (ServletException | IOException e) {
        throw new MediaIOException("media.persist");
    }
}
 
开发者ID:JUGIstanbul,项目名称:second-opinion-api,代码行数:10,代码来源:MediaController.java

示例11: createPhotoContribution

@ApiOperation(value = "Create the contribution of photos")
@ApiResponses(value = {
        @ApiResponse(code = 400, message = "Incorrect data"),
        @ApiResponse(code = 404, message = "No movie found or no user found"),
        @ApiResponse(code = 409, message = "An ID conflict or element exists"),
        @ApiResponse(code = 412, message = "An I/O error occurs or incorrect content type"),
        @ApiResponse(code = 500, message = "An error occurred with the server")
})
@PreAuthorize("hasRole('ROLE_USER')")
@PostMapping(value = "/{id}/contributions/photos", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@ResponseStatus(HttpStatus.CREATED)
public
ResponseEntity<Void> createPhotoContribution(
        @ApiParam(value = "The movie ID", required = true)
        @PathVariable("id") final Long id,
        @ApiParam(value = "Elements to be added")
        @RequestPart(required = false) List<MultipartFile> elementsToAdd,
        @ApiParam(value = "Element IDs to be updated")
        @RequestParam(defaultValue = "", required = false) Set<Long> idsToUpdate,
        @ApiParam(value = "Element to be updated")
        @RequestPart(required = false) List<MultipartFile> elementsToUpdate,
        @ApiParam(value = "Element IDs to be deleted")
        @RequestParam(defaultValue = "", required = false) Set<Long> idsToDelete,
        @ApiParam(value = "Sources of information(elements)", required = true)
        @RequestParam final Set<String> sources,
        @ApiParam(value = "Comment from the user")
        @RequestParam(required = false) final String comment
) {
    log.info("Called with id {}, elementsToAdd {}, idsToUpdate {}, elementsToUpdate{}, idsToDelete {}," +
                    " sources {}, comment {}",
            id, elementsToAdd, idsToUpdate, elementsToUpdate, idsToDelete, sources, comment);

    final ContributionNew<ImageRequest> contribution = new ContributionNew<>();

    final List<ImageRequest> listPhotosToAdd = new ArrayList<>();
    for(final MultipartFile multipartFile : elementsToAdd) {
        final ImageRequest.Builder builder = new ImageRequest.Builder().withFile(MultipartFileUtils.convert(multipartFile));
        listPhotosToAdd.add(builder.build());
    }
    contribution.setElementsToAdd(listPhotosToAdd);

    final HashMap<Long, ImageRequest> mapPhotosToUpdate = MapUtils.merge(idsToUpdate, elementsToUpdate);
    contribution.setElementsToUpdate(mapPhotosToUpdate);

    contribution.setIdsToDelete(idsToDelete);
    contribution.setSources(sources);

    final Long cId = this.movieContributionPersistenceService.createPhotoContribution(contribution, id, this.authorizationService.getUserId());

    final HttpHeaders httpHeaders = new HttpHeaders();
    httpHeaders.setLocation(
            MvcUriComponentsBuilder
                    .fromMethodName(MovieContributionRestController.class, "getPhotoContribution", cId)
                    .buildAndExpand(cId)
                    .toUri()
    );

    return new ResponseEntity<>(httpHeaders, HttpStatus.CREATED);
}
 
开发者ID:JonkiPro,项目名称:REST-Web-Services,代码行数:59,代码来源:MovieContributionRestController.java

示例12: updatePhotoContribution

@ApiOperation(value = "Update the contribution of photos")
@ApiResponses(value = {
        @ApiResponse(code = 400, message = "Incorrect data"),
        @ApiResponse(code = 404, message = "No movie found or no user found"),
        @ApiResponse(code = 409, message = "An ID conflict or element exists"),
        @ApiResponse(code = 412, message = "An I/O error occurs or incorrect content type"),
        @ApiResponse(code = 500, message = "An error occurred with the server")
})
@PreAuthorize("hasRole('ROLE_USER')")
@PutMapping(value = "/contributions/{id}/photos", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public
void updatePhotoContribution(
        @ApiParam(value = "The movie ID", required = true)
        @PathVariable("id") final Long id,
        @ApiParam(value = "New elements to be added")
        @RequestPart(required = false) List<MultipartFile> newElementsToAdd,
        @ApiParam(value = "Element IDs to be added")
        @RequestParam(defaultValue = "", required = false) Set<Long> idsToAdd,
        @ApiParam(value = "Element to be updated")
        @RequestPart(required = false) List<MultipartFile> elementsToAdd,
        @ApiParam(value = "Element IDs to be updated")
        @RequestParam(defaultValue = "", required = false) Set<Long> idsToUpdate,
        @ApiParam(value = "Element to be updated")
        @RequestPart(required = false) List<MultipartFile> elementsToUpdate,
        @ApiParam(value = "Element IDs to be deleted")
        @RequestParam(defaultValue = "", required = false) Set<Long> idsToDelete,
        @ApiParam(value = "Sources of information(elements)", required = true)
        @RequestParam final Set<String> sources,
        @ApiParam(value = "Comment from the user")
        @RequestParam(required = false) final String comment
) {
    log.info("Called with id {}, idsToAdd {}, elementsToAdd{}, newElementsToAdd {}, idsToUpdate {}," +
            "elementsToUpdate {}, idsToDelete {}, sources {}, comment {}", id, idsToAdd,
            elementsToAdd, newElementsToAdd, idsToUpdate, elementsToUpdate, idsToDelete, sources, comment);

    final ContributionUpdate<ImageRequest> contribution = new ContributionUpdate<>();

    final HashMap<Long, ImageRequest> mapPhotosToAdd = MapUtils.merge(idsToAdd, elementsToAdd);
    contribution.setElementsToAdd(mapPhotosToAdd);

    final List<ImageRequest> listNewPhotosToAdd = new ArrayList<>();
    for(final MultipartFile multipartFile : newElementsToAdd) {
        final ImageRequest.Builder builder = new ImageRequest.Builder().withFile(MultipartFileUtils.convert(multipartFile));
        listNewPhotosToAdd.add(builder.build());
    }
    contribution.setNewElementsToAdd(listNewPhotosToAdd);

    final HashMap<Long, ImageRequest> mapPhotosToUpdate = MapUtils.merge(idsToUpdate, elementsToUpdate);
    contribution.setElementsToUpdate(mapPhotosToUpdate);

    contribution.setIdsToDelete(idsToDelete);
    contribution.setSources(sources);

    this.movieContributionPersistenceService.updatePhotoContribution(contribution, id, this.authorizationService.getUserId());
}
 
开发者ID:JonkiPro,项目名称:REST-Web-Services,代码行数:56,代码来源:MovieContributionRestController.java

示例13: createPosterContribution

@ApiOperation(value = "Create the contribution of posters")
@ApiResponses(value = {
        @ApiResponse(code = 400, message = "Incorrect data"),
        @ApiResponse(code = 404, message = "No movie found or no user found"),
        @ApiResponse(code = 409, message = "An ID conflict or element exists"),
        @ApiResponse(code = 412, message = "An I/O error occurs or incorrect content type"),
        @ApiResponse(code = 500, message = "An error occurred with the server")
})
@PreAuthorize("hasRole('ROLE_USER')")
@PostMapping(value = "/{id}/contributions/posters", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@ResponseStatus(HttpStatus.CREATED)
public
ResponseEntity<Void> createPosterContribution(
        @ApiParam(value = "The movie ID", required = true)
        @PathVariable("id") final Long id,
        @ApiParam(value = "Elements to be added")
        @RequestPart(required = false) List<MultipartFile> elementsToAdd,
        @ApiParam(value = "Element IDs to be updated")
        @RequestParam(defaultValue = "", required = false) Set<Long> idsToUpdate,
        @ApiParam(value = "Element to be updated")
        @RequestPart(required = false) List<MultipartFile> elementsToUpdate,
        @ApiParam(value = "Element IDs to be deleted")
        @RequestParam(defaultValue = "", required = false) Set<Long> idsToDelete,
        @ApiParam(value = "Sources of information(elements)", required = true)
        @RequestParam final Set<String> sources,
        @ApiParam(value = "Comment from the user")
        @RequestParam(required = false) final String comment
) {
    log.info("Called with id {}, elementsToAdd {}, idsToUpdate {}, elementsToUpdate{}, idsToDelete {}," +
                    " sources {}, comment {}",
            id, elementsToAdd, idsToUpdate, elementsToUpdate, idsToDelete, sources, comment);

    final ContributionNew<ImageRequest> contribution = new ContributionNew<>();

    final List<ImageRequest> listPhotosToAdd = new ArrayList<>();
    for(final MultipartFile multipartFile : elementsToAdd) {
        final ImageRequest.Builder builder = new ImageRequest.Builder().withFile(MultipartFileUtils.convert(multipartFile));
        listPhotosToAdd.add(builder.build());
    }
    contribution.setElementsToAdd(listPhotosToAdd);

    final HashMap<Long, ImageRequest> mapPhotosToUpdate = MapUtils.merge(idsToUpdate, elementsToUpdate);
    contribution.setElementsToUpdate(mapPhotosToUpdate);

    contribution.setIdsToDelete(idsToDelete);
    contribution.setSources(sources);

    final Long cId = this.movieContributionPersistenceService.createPosterContribution(contribution, id, this.authorizationService.getUserId());

    final HttpHeaders httpHeaders = new HttpHeaders();
    httpHeaders.setLocation(
            MvcUriComponentsBuilder
                    .fromMethodName(MovieContributionRestController.class, "getPosterContribution", cId)
                    .buildAndExpand(cId)
                    .toUri()
    );

    return new ResponseEntity<>(httpHeaders, HttpStatus.CREATED);
}
 
开发者ID:JonkiPro,项目名称:REST-Web-Services,代码行数:59,代码来源:MovieContributionRestController.java

示例14: updatePosterContribution

@ApiOperation(value = "Update the contribution of posters")
@ApiResponses(value = {
        @ApiResponse(code = 400, message = "Incorrect data"),
        @ApiResponse(code = 404, message = "No movie found or no user found"),
        @ApiResponse(code = 409, message = "An ID conflict or element exists"),
        @ApiResponse(code = 412, message = "An I/O error occurs or incorrect content type"),
        @ApiResponse(code = 500, message = "An error occurred with the server")
})
@PreAuthorize("hasRole('ROLE_USER')")
@PutMapping(value = "/contributions/{id}/posters", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public
void updatePosterContribution(
        @ApiParam(value = "The movie ID", required = true)
        @PathVariable("id") final Long id,
        @ApiParam(value = "New elements to be added")
        @RequestPart(required = false) List<MultipartFile> newElementsToAdd,
        @ApiParam(value = "Element IDs to be added")
        @RequestParam(defaultValue = "", required = false) Set<Long> idsToAdd,
        @ApiParam(value = "Element to be updated")
        @RequestPart(required = false) List<MultipartFile> elementsToAdd,
        @ApiParam(value = "Element IDs to be updated")
        @RequestParam(defaultValue = "", required = false) Set<Long> idsToUpdate,
        @ApiParam(value = "Element to be updated")
        @RequestPart(required = false) List<MultipartFile> elementsToUpdate,
        @ApiParam(value = "Element IDs to be deleted")
        @RequestParam(defaultValue = "", required = false) Set<Long> idsToDelete,
        @ApiParam(value = "Sources of information(elements)", required = true)
        @RequestParam final Set<String> sources,
        @ApiParam(value = "Comment from the user")
        @RequestParam(required = false) final String comment
) {
    log.info("Called with id {}, idsToAdd {}, elementsToAdd{}, newElementsToAdd {}, idsToUpdate {}," +
                    "elementsToUpdate {}, idsToDelete {}, sources {}, comment {}", id, idsToAdd,
            elementsToAdd, newElementsToAdd, idsToUpdate, elementsToUpdate, idsToDelete, sources, comment);

    final ContributionUpdate<ImageRequest> contribution = new ContributionUpdate<>();

    final HashMap<Long, ImageRequest> mapPhotosToAdd = MapUtils.merge(idsToAdd, elementsToAdd);
    contribution.setElementsToAdd(mapPhotosToAdd);

    final List<ImageRequest> listNewPhotosToAdd = new ArrayList<>();
    for(final MultipartFile multipartFile : newElementsToAdd) {
        final ImageRequest.Builder builder = new ImageRequest.Builder().withFile(MultipartFileUtils.convert(multipartFile));
        listNewPhotosToAdd.add(builder.build());
    }
    contribution.setNewElementsToAdd(listNewPhotosToAdd);

    final HashMap<Long, ImageRequest> mapPhotosToUpdate = MapUtils.merge(idsToUpdate, elementsToUpdate);
    contribution.setElementsToUpdate(mapPhotosToUpdate);

    contribution.setIdsToDelete(idsToDelete);
    contribution.setSources(sources);

    this.movieContributionPersistenceService.updatePosterContribution(contribution, id, this.authorizationService.getUserId());
}
 
开发者ID:JonkiPro,项目名称:REST-Web-Services,代码行数:56,代码来源:MovieContributionRestController.java


注:本文中的org.springframework.http.MediaType.MULTIPART_FORM_DATA_VALUE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。