org.springframework.web.bind.annotation.RequestPart Java Examples
The following examples show how to use
org.springframework.web.bind.annotation.RequestPart.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PetApi.java From openapi-generator with Apache License 2.0 | 6 votes |
/** * POST /pet/{petId}/uploadImage : uploads an image * * @param petId ID of pet to update (required) * @param additionalMetadata Additional data to pass to server (optional) * @param file file to upload (optional) * @return successful operation (status code 200) */ @ApiOperation(value = "uploads an image", nickname = "uploadFile", notes = "", response = ModelApiResponse.class, authorizations = { @Authorization(value = "petstore_auth", scopes = { @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), @AuthorizationScope(scope = "read:pets", description = "read your pets") }) }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) @RequestMapping(value = "/pet/{petId}/uploadImage", produces = { "application/json" }, consumes = { "multipart/form-data" }, method = RequestMethod.POST) default ResponseEntity<ModelApiResponse> uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata,@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { String exampleString = "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\" }"; ApiUtil.setExampleResponse(request, "application/json", exampleString); break; } } }); return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); }
Example #2
Source File: UploadController.java From Spring with Apache License 2.0 | 6 votes |
/** * curl -F file=@/home/olinnyk/IdeaProjects/Spring/SpringWEB/SpringBoot/just-gif-it/video/PexelsVideos.mp4 -F start=0 -F end=5 -F speed=1 -F repeat=0 localhost:8080/upload */ @PostMapping @RequestMapping(value = "/upload", produces = MediaType.IMAGE_GIF_VALUE) public String upload(@RequestPart("file") MultipartFile file, @RequestParam("start") int start, @RequestParam("end") int end, @RequestParam("speed") int speed, @RequestParam("repeat") boolean repeat) throws IOException, FrameGrabber.Exception { final File videoFile = new File(location + "/" + System.currentTimeMillis() + ".mp4"); file.transferTo(videoFile); log.info("Saved video file to {}", videoFile.getAbsolutePath()); final Path output = Paths.get(location + "/gif/" + System.currentTimeMillis() + ".gif"); final FFmpegFrameGrabber frameGrabber = videoDecoderService.read(videoFile); final AnimatedGifEncoder gifEncoder = gifEncoderService.getGifEncoder(repeat, (float) frameGrabber.getFrameRate(), output); converterService.toAnimatedGif(frameGrabber, gifEncoder, start, end, speed); log.info("Saved generated gif to {}", output.toString()); return output.getFileName().toString(); }
Example #3
Source File: PetApi.java From openapi-generator with Apache License 2.0 | 6 votes |
/** * POST /pet/{petId}/uploadImage : uploads an image * * @param petId ID of pet to update (required) * @param additionalMetadata Additional data to pass to server (optional) * @param file file to upload (optional) * @return successful operation (status code 200) */ @ApiOperation(value = "uploads an image", nickname = "uploadFile", notes = "", response = ModelApiResponse.class, authorizations = { @Authorization(value = "petstore_auth", scopes = { @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), @AuthorizationScope(scope = "read:pets", description = "read your pets") }) }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) @RequestMapping(value = "/pet/{petId}/uploadImage", produces = { "application/json" }, consumes = { "multipart/form-data" }, method = RequestMethod.POST) default ResponseEntity<ModelApiResponse> uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata,@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { String exampleString = "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\" }"; ApiUtil.setExampleResponse(request, "application/json", exampleString); break; } } }); return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); }
Example #4
Source File: PetApi.java From openapi-generator with Apache License 2.0 | 6 votes |
/** * POST /pet/{petId} : Updates a pet in the store with form data * * @param petId ID of pet that needs to be updated (required) * @param name Updated name of the pet (optional) * @param status Updated status of the pet (optional) * @return Invalid input (status code 405) */ @ApiOperation(value = "Updates a pet in the store with form data", nickname = "updatePetWithForm", notes = "", authorizations = { @Authorization(value = "petstore_auth", scopes = { @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), @AuthorizationScope(scope = "read:pets", description = "read your pets") }) }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 405, message = "Invalid input") }) @RequestMapping(value = "/pet/{petId}", consumes = { "application/x-www-form-urlencoded" }, method = RequestMethod.POST) default ResponseEntity<Void> updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @Valid @RequestPart(value = "name", required = false) String name,@ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); }
Example #5
Source File: PetApi.java From openapi-generator with Apache License 2.0 | 6 votes |
/** * POST /pet/{petId}/uploadImage : uploads an image * * @param petId ID of pet to update (required) * @param additionalMetadata Additional data to pass to server (optional) * @param file file to upload (optional) * @return successful operation (status code 200) */ @ApiOperation(value = "uploads an image", nickname = "uploadFile", notes = "", response = ModelApiResponse.class, authorizations = { @Authorization(value = "petstore_auth", scopes = { @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), @AuthorizationScope(scope = "read:pets", description = "read your pets") }) }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) @RequestMapping(value = "/pet/{petId}/uploadImage", produces = "application/json", consumes = "multipart/form-data", method = RequestMethod.POST) default ResponseEntity<ModelApiResponse> uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata,@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { String exampleString = "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\" }"; ApiUtil.setExampleResponse(request, "application/json", exampleString); break; } } }); return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); }
Example #6
Source File: IntermediatePathApi.java From swagger-aem with Apache License 2.0 | 6 votes |
@ApiOperation(value = "", nickname = "postAuthorizableKeystore", notes = "", response = KeystoreInfo.class, authorizations = { @Authorization(value = "aemAuth") }, tags={ "sling", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Retrieved Authorizable Keystore info", response = KeystoreInfo.class), @ApiResponse(code = 200, message = "Default response", response = String.class) }) @RequestMapping(value = "/{intermediatePath}/{authorizableId}.ks.html", produces = { "text/plain" }, consumes = { "multipart/form-data" }, method = RequestMethod.POST) default ResponseEntity<KeystoreInfo> postAuthorizableKeystore(@ApiParam(value = "",required=true) @PathVariable("intermediatePath") String intermediatePath,@ApiParam(value = "",required=true) @PathVariable("authorizableId") String authorizableId,@ApiParam(value = "") @Valid @RequestParam(value = ":operation", required = false) String colonOperation,@ApiParam(value = "") @Valid @RequestParam(value = "currentPassword", required = false) String currentPassword,@ApiParam(value = "") @Valid @RequestParam(value = "newPassword", required = false) String newPassword,@ApiParam(value = "") @Valid @RequestParam(value = "rePassword", required = false) String rePassword,@ApiParam(value = "") @Valid @RequestParam(value = "keyPassword", required = false) String keyPassword,@ApiParam(value = "") @Valid @RequestParam(value = "keyStorePass", required = false) String keyStorePass,@ApiParam(value = "") @Valid @RequestParam(value = "alias", required = false) String alias,@ApiParam(value = "") @Valid @RequestParam(value = "newAlias", required = false) String newAlias,@ApiParam(value = "") @Valid @RequestParam(value = "removeAlias", required = false) String removeAlias,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile cert-chain,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile pk,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile keyStore) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf(""))) { ApiUtil.setExampleResponse(request, "", ""); break; } } }); return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } }
Example #7
Source File: SlingApi.java From swagger-aem with Apache License 2.0 | 6 votes |
@ApiOperation(value = "", notes = "", response = KeystoreInfo.class, authorizations = { @Authorization(value = "aemAuth") }, tags={ "sling", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Retrieved Authorizable Keystore info", response = KeystoreInfo.class), @ApiResponse(code = 200, message = "Default response", response = String.class) }) @RequestMapping(value = "/{intermediatePath}/{authorizableId}.ks.html", produces = { "text/plain" }, consumes = { "multipart/form-data" }, method = RequestMethod.POST) ResponseEntity<KeystoreInfo> postAuthorizableKeystore(@ApiParam(value = "",required=true ) @PathVariable("intermediatePath") String intermediatePath,@ApiParam(value = "",required=true ) @PathVariable("authorizableId") String authorizableId,@ApiParam(value = "") @RequestParam(value = ":operation", required = false) String colonOperation,@ApiParam(value = "") @RequestParam(value = "currentPassword", required = false) String currentPassword,@ApiParam(value = "") @RequestParam(value = "newPassword", required = false) String newPassword,@ApiParam(value = "") @RequestParam(value = "rePassword", required = false) String rePassword,@ApiParam(value = "") @RequestParam(value = "keyPassword", required = false) String keyPassword,@ApiParam(value = "") @RequestParam(value = "keyStorePass", required = false) String keyStorePass,@ApiParam(value = "") @RequestParam(value = "alias", required = false) String alias,@ApiParam(value = "") @RequestParam(value = "newAlias", required = false) String newAlias,@ApiParam(value = "") @RequestParam(value = "removeAlias", required = false) String removeAlias,@ApiParam(value = "file detail") @RequestPart("file") MultipartFile cert-chain,@ApiParam(value = "file detail") @RequestPart("file") MultipartFile pk,@ApiParam(value = "file detail") @RequestPart("file") MultipartFile keyStore, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "", notes = "", response = String.class, authorizations = { @Authorization(value = "aemAuth") }, tags={ "sling", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Default response", response = String.class) }) @RequestMapping(value = "/libs/granite/security/post/authorizables", produces = { "text/html" }
Example #8
Source File: FakeApi.java From openapi-generator with Apache License 2.0 | 6 votes |
/** * POST /fake/{petId}/uploadImageWithRequiredFile : uploads an image (required) * * @param petId ID of pet to update (required) * @param requiredFile file to upload (required) * @param additionalMetadata Additional data to pass to server (optional) * @return successful operation (status code 200) */ @ApiOperation(value = "uploads an image (required)", nickname = "uploadFileWithRequiredFile", notes = "", response = ModelApiResponse.class, authorizations = { @Authorization(value = "petstore_auth", scopes = { @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), @AuthorizationScope(scope = "read:pets", description = "read your pets") }) }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) @RequestMapping(value = "/fake/{petId}/uploadImageWithRequiredFile", produces = { "application/json" }, consumes = { "multipart/form-data" }, method = RequestMethod.POST) default ResponseEntity<ModelApiResponse> uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "file to upload") @Valid @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile,@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata) { return getDelegate().uploadFileWithRequiredFile(petId, requiredFile, additionalMetadata); }
Example #9
Source File: ValidFeignClientTests.java From spring-cloud-openfeign with Apache License 2.0 | 5 votes |
@RequestMapping(method = RequestMethod.POST, path = "/multipartPojo", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.TEXT_PLAIN_VALUE) String multipartPojo(@RequestPart("hello") String hello, @RequestPart("world") String world, @RequestPart("pojo1") Hello pojo1, @RequestPart("pojo2") Hello pojo2, @RequestPart("file") MultipartFile file) { return hello + world + pojo1.getMessage() + pojo2.getMessage() + file.getOriginalFilename(); }
Example #10
Source File: ServerMain.java From feign-client-test with MIT License | 5 votes |
@RequestMapping(path = "/uploadArray/{folder}", method = POST) public HttpEntity<List<UploadInfo>> uploadArray(@PathVariable String folder, @RequestPart MultipartFile[] files, @RequestPart UploadMetadata metadata) { List<UploadInfo> response = new ArrayList<>(); for (MultipartFile file : files) { response.add(new UploadInfo(i++, file.getSize(), folder + "/" + file.getOriginalFilename())); } return ResponseEntity.ok(response); }
Example #11
Source File: UploadController.java From Learning-Spring-Boot-2.0-Second-Edition with MIT License | 5 votes |
@PostMapping(value = BASE_PATH) public Mono<String> createFile( @RequestPart("file") Flux<FilePart> files, @AuthenticationPrincipal Principal principal) { return imageService.createImage(files, principal) .then(Mono.just("redirect:/")); }
Example #12
Source File: FakeApi.java From openapi-generator with Apache License 2.0 | 5 votes |
/** * POST /fake/{petId}/uploadImageWithRequiredFile : uploads an image (required) * * @param petId ID of pet to update (required) * @param requiredFile file to upload (required) * @param additionalMetadata Additional data to pass to server (optional) * @return successful operation (status code 200) */ @ApiOperation(value = "uploads an image (required)", nickname = "uploadFileWithRequiredFile", notes = "", response = ModelApiResponse.class, authorizations = { @Authorization(value = "petstore_auth", scopes = { @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), @AuthorizationScope(scope = "read:pets", description = "read your pets") }) }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) @RequestMapping(value = "/fake/{petId}/uploadImageWithRequiredFile", produces = { "application/json" }, consumes = { "multipart/form-data" }, method = RequestMethod.POST) ResponseEntity<ModelApiResponse> uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "file to upload") @Valid @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile,@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata);
Example #13
Source File: PetApiController.java From openapi-generator with Apache License 2.0 | 5 votes |
/** * POST /pet/{petId}/uploadImage : uploads an image * * @param petId ID of pet to update (required) * @param additionalMetadata Additional data to pass to server (optional) * @param file file to upload (optional) * @return successful operation (status code 200) * @see PetApi#uploadFile */ public ResponseEntity<ModelApiResponse> uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata,@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file) { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { String exampleString = "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\" }"; ApiUtil.setExampleResponse(request, "application/json", exampleString); break; } } return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); }
Example #14
Source File: MigrateController.java From halo with GNU General Public License v3.0 | 5 votes |
@PostMapping("halo") @ApiOperation("Migrate from Halo") public void migrateHalo(@RequestPart("file") MultipartFile file) { if (optionService.getByPropertyOrDefault(PrimaryProperties.IS_INSTALLED, Boolean.class, false)) { throw new BadRequestException("无法在博客初始化完成之后迁移数据"); } migrateService.migrate(file, MigrateType.HALO); }
Example #15
Source File: FakeApi.java From openapi-generator with Apache License 2.0 | 5 votes |
/** * POST /fake/{petId}/uploadImageWithRequiredFile : uploads an image (required) * * @param petId ID of pet to update (required) * @param requiredFile file to upload (required) * @param additionalMetadata Additional data to pass to server (optional) * @return successful operation (status code 200) */ @ApiOperation(value = "uploads an image (required)", nickname = "uploadFileWithRequiredFile", notes = "", response = ModelApiResponse.class, authorizations = { @Authorization(value = "petstore_auth", scopes = { @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), @AuthorizationScope(scope = "read:pets", description = "read your pets") }) }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) @RequestMapping(value = "/fake/{petId}/uploadImageWithRequiredFile", produces = { "application/json" }, consumes = { "multipart/form-data" }, method = RequestMethod.POST) default CompletableFuture<ResponseEntity<ModelApiResponse>> uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "file to upload") @Valid @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile,@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata) { return CompletableFuture.supplyAsync(()-> { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { String exampleString = "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\" }"; ApiUtil.setExampleResponse(request, "application/json", exampleString); break; } } }); return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); }, Runnable::run); }
Example #16
Source File: RequestPartMethodArgumentResolver.java From java-technology-stack with MIT License | 5 votes |
private String getPartName(MethodParameter methodParam, @Nullable RequestPart requestPart) { String partName = (requestPart != null ? requestPart.name() : ""); if (partName.isEmpty()) { partName = methodParam.getParameterName(); if (partName == null) { throw new IllegalArgumentException("Request part name for argument type [" + methodParam.getNestedParameterType().getName() + "] not specified, and parameter name information not found in class file either."); } } return partName; }
Example #17
Source File: PetApi.java From openapi-generator with Apache License 2.0 | 5 votes |
/** * POST /pet/{petId}/uploadImage : uploads an image * * @param petId ID of pet to update (required) * @param additionalMetadata Additional data to pass to server (optional) * @param file file to upload (optional) * @return successful operation (status code 200) */ @ApiOperation(value = "uploads an image", nickname = "uploadFile", notes = "", response = ModelApiResponse.class, authorizations = { @Authorization(value = "petstore_auth", scopes = { @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), @AuthorizationScope(scope = "read:pets", description = "read your pets") }) }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) @RequestMapping(value = "/pet/{petId}/uploadImage", produces = { "application/json" }, consumes = { "multipart/form-data" }, method = RequestMethod.POST) default CompletableFuture<ResponseEntity<ModelApiResponse>> uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata,@ApiParam(value = "file to upload") @Valid @RequestPart(value = "file", required = false) MultipartFile file) { return CompletableFuture.supplyAsync(()-> { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { String exampleString = "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\" }"; ApiUtil.setExampleResponse(request, "application/json", exampleString); break; } } }); return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); }, Runnable::run); }
Example #18
Source File: FakeApi.java From openapi-generator with Apache License 2.0 | 5 votes |
/** * POST /fake/{petId}/uploadImageWithRequiredFile : uploads an image (required) * * @param petId ID of pet to update (required) * @param requiredFile file to upload (required) * @param additionalMetadata Additional data to pass to server (optional) * @return successful operation (status code 200) */ @ApiOperation(value = "uploads an image (required)", nickname = "uploadFileWithRequiredFile", notes = "", response = ModelApiResponse.class, authorizations = { @Authorization(value = "petstore_auth", scopes = { @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), @AuthorizationScope(scope = "read:pets", description = "read your pets") }) }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) @RequestMapping(value = "/fake/{petId}/uploadImageWithRequiredFile", produces = { "application/json" }, consumes = { "multipart/form-data" }, method = RequestMethod.POST) ResponseEntity<ModelApiResponse> uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "file to upload") @Valid @RequestPart(value = "requiredFile", required = true) MultipartFile requiredFile,@ApiParam(value = "Additional data to pass to server") @Valid @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata);
Example #19
Source File: PetApi.java From openapi-generator with Apache License 2.0 | 5 votes |
/** * POST /pet/{petId} : Updates a pet in the store with form data * * @param petId ID of pet that needs to be updated (required) * @param name Updated name of the pet (optional) * @param status Updated status of the pet (optional) * @return Invalid input (status code 405) */ @ApiOperation(value = "Updates a pet in the store with form data", nickname = "updatePetWithForm", notes = "", authorizations = { @Authorization(value = "petstore_auth", scopes = { @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), @AuthorizationScope(scope = "read:pets", description = "read your pets") }) }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 405, message = "Invalid input") }) @RequestMapping(value = "/pet/{petId}", consumes = { "application/x-www-form-urlencoded" }, method = RequestMethod.POST) ResponseEntity<Void> updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @Valid @RequestPart(value = "name", required = false) String name,@ApiParam(value = "Updated status of the pet") @Valid @RequestPart(value = "status", required = false) String status);
Example #20
Source File: UploadController.java From Learning-Spring-Boot-2.0-Second-Edition with MIT License | 5 votes |
@PostMapping(value = BASE_PATH) public Mono<String> createFile( @RequestPart("file") Flux<FilePart> files, @AuthenticationPrincipal Principal principal) { return imageService.createImage(files, principal) .then(Mono.just("redirect:/")); }
Example #21
Source File: MultipartControllerTests.java From java-technology-stack with MIT License | 5 votes |
@RequestMapping(value = "/multipartfilelist", method = RequestMethod.POST) public String processMultipartFileList(@RequestParam(required = false) List<MultipartFile> file, @RequestPart(required = false) Map<String, String> json, Model model) throws IOException { if (file != null && !file.isEmpty()) { byte[] content = file.get(0).getBytes(); Assert.assertArrayEquals(content, file.get(1).getBytes()); model.addAttribute("fileContent", content); } if (json != null) { model.addAttribute("jsonContent", json); } return "redirect:/index"; }
Example #22
Source File: ApiController.java From Learning-Spring-Boot-2.0-Second-Edition with MIT License | 5 votes |
@PostMapping(API_BASE_PATH + "/images") Mono<Void> create(@RequestPart Flux<FilePart> images) { Hooks.onOperatorDebug(); return images .map(image -> { log.info("We will save " + image + " to a Reactive database soon!"); return image; }) .then(); }
Example #23
Source File: MultipartControllerTests.java From spring-analysis-note with MIT License | 5 votes |
@RequestMapping(value = "/part", method = RequestMethod.POST) public String processPart(@RequestParam Part part, @RequestPart Map<String, String> json, Model model) throws IOException { model.addAttribute("fileContent", part.getInputStream()); model.addAttribute("jsonContent", json); return "redirect:/index"; }
Example #24
Source File: FakeApi.java From openapi-generator with Apache License 2.0 | 5 votes |
/** * GET /fake/jsonFormData : test json serialization of form data * * @param param field1 (required) * @param param2 field2 (required) * @return successful operation (status code 200) */ @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) @RequestMapping(value = "/fake/jsonFormData", consumes = { "application/x-www-form-urlencoded" }, method = RequestMethod.GET) ResponseEntity<Void> testJsonFormData(@ApiParam(value = "field1", required=true) @Valid @RequestPart(value = "param", required = true) String param,@ApiParam(value = "field2", required=true) @Valid @RequestPart(value = "param2", required = true) String param2);
Example #25
Source File: RequestPartMethodArgumentResolver.java From lams with GNU General Public License v2.0 | 5 votes |
private String getPartName(MethodParameter methodParam, RequestPart requestPart) { String partName = (requestPart != null ? requestPart.name() : ""); if (partName.isEmpty()) { partName = methodParam.getParameterName(); if (partName == null) { throw new IllegalArgumentException("Request part name for argument type [" + methodParam.getNestedParameterType().getName() + "] not specified, and parameter name information not found in class file either."); } } return partName; }
Example #26
Source File: HelloController.java From springdoc-openapi with Apache License 2.0 | 5 votes |
@PostMapping(value = "/test/103", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) @Operation( requestBody = @RequestBody( content = @Content( encoding = @Encoding(name = "body", contentType = "application/json") ) ) ) public String postMyRequestBody( @RequestPart("body") ExampleBody body, @RequestParam("file") MultipartFile file ) { return null; }
Example #27
Source File: PetApi.java From springdoc-openapi with Apache License 2.0 | 5 votes |
@Operation(summary = "uploads an image", description = "", security = { @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = ModelApiResponse.class))) }) @PostMapping(value = "/pet/{petId}/uploadImage", produces = { "application/json" }, consumes = { "multipart/form-data" }) default ResponseEntity<ModelApiResponse> uploadFile( @Parameter(description = "ID of pet to update", required = true) @PathVariable("petId") Long petId, @Parameter(description = "Additional data to pass to server") @RequestParam(value = "additionalMetadata", required = false) String additionalMetadata, @Parameter(description = "file detail") @Valid @RequestPart("file") MultipartFile file) { return getDelegate().uploadFile(petId, additionalMetadata, file); }
Example #28
Source File: FakeApi.java From openapi-generator with Apache License 2.0 | 5 votes |
/** * GET /fake/jsonFormData : test json serialization of form data * * @param param field1 (required) * @param param2 field2 (required) * @return successful operation (status code 200) */ @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) @RequestMapping(value = "/fake/jsonFormData", consumes = { "application/x-www-form-urlencoded" }, method = RequestMethod.GET) default ResponseEntity<Void> testJsonFormData(@ApiParam(value = "field1", required=true) @Valid @RequestPart(value = "param", required = true) String param,@ApiParam(value = "field2", required=true) @Valid @RequestPart(value = "param2", required = true) String param2) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); }
Example #29
Source File: CustomizationAdminController.java From find with MIT License | 5 votes |
@RequestMapping(value = TYPED_ASSETS_PATH, method = RequestMethod.PUT) public ResponseEntity<Status> putLogo( @PathVariable("type") final AssetType assetType, @RequestPart("file") final MultipartFile file ) throws CustomizationException { return saveLogo(assetType, file, true); }
Example #30
Source File: ValidFeignClientTests.java From spring-cloud-openfeign with Apache License 2.0 | 5 votes |
@RequestMapping(method = RequestMethod.POST, path = "/multipart", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.TEXT_PLAIN_VALUE) String multipart(@RequestPart("hello") String hello, @RequestPart("world") String world, @RequestPart("file") MultipartFile file) { return hello + world + file.getOriginalFilename(); }