org.springframework.web.bind.annotation.RequestPart源码实例Demo

类org.springframework.web.bind.annotation.RequestPart源码实例Demo

下面列出了怎么用org.springframework.web.bind.annotation.RequestPart的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: openapi-generator   文件: PetApi.java
/**
 * 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);

}
 
源代码2 项目: Spring   文件: UploadController.java
/**
 * curl -F [email protected]/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();
}
 
源代码3 项目: openapi-generator   文件: PetApi.java
/**
 * 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);

}
 
源代码4 项目: openapi-generator   文件: PetApi.java
/**
 * 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);

}
 
源代码5 项目: swagger-aem   文件: SlingApi.java
@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" }
 
源代码6 项目: swagger-aem   文件: IntermediatePathApi.java
@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);

    }

}
 
源代码7 项目: openapi-generator   文件: PetApi.java
/**
 * 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);

}
 
源代码8 项目: openapi-generator   文件: FakeApi.java
/**
 * 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);
}
 
源代码9 项目: feign-form   文件: Server.java
@PostMapping(path = "/upload/unknown_type", consumes = MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<String> uploadUnknownType (@RequestPart("file") MultipartFile file) {
  val status = file != null
               ? OK
               : I_AM_A_TEAPOT;
  return ResponseEntity.status(status).body(file.getContentType());
}
 
源代码10 项目: halo   文件: MigrateController.java
@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);
}
 
源代码11 项目: feign-form   文件: Server.java
@PostMapping(path = "/upload/with_dto", consumes = MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<Long> uploadWithDto (Dto dto, @RequestPart("file") MultipartFile file
) throws IOException {
  val status = dto != null && dto.getName().equals("Artem")
               ? OK
               : I_AM_A_TEAPOT;
  return ResponseEntity.status(status).body(file.getSize());
}
 
源代码12 项目: openapi-generator   文件: PetApi.java
/**
 * 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 Mono<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, ServerWebExchange exchange) {
    return getDelegate().updatePetWithForm(petId, name, status, exchange);
}
 
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;
}
 
@SuppressWarnings("unused")
void handle(
		@RequestPart("name") Person person,
		@RequestPart("name") Mono<Person> personMono,
		@RequestPart("name") Flux<Person> personFlux,
		@RequestPart("name") List<Person> personList,
		@RequestPart("name") Part part,
		@RequestPart("name") Mono<Part> partMono,
		@RequestPart("name") Flux<Part> partFlux,
		@RequestPart("name") List<Part> partList,
		@RequestPart(name = "anotherPart", required = false) Person anotherPerson,
		@RequestPart(name = "anotherPart", required = false) Part anotherPart,
		Person notAnnotated) {}
 
@PostMapping(API_BASE_PATH + "/images")
Mono<Void> create(@RequestPart Flux<FilePart> images) {
	return images
		.map(image -> {
			log.info("We will save " + image +
				" to a Reactive database soon!");
			return image;
		})
		.then();
}
 
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;
}
 
源代码17 项目: openapi-generator   文件: FakeApi.java
/**
 * 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);
 
源代码18 项目: feign-form   文件: Server.java
@RequestMapping(
    path = "/multipart/upload1/{folder}",
    method = POST,
    consumes = MULTIPART_FORM_DATA_VALUE
)
@SneakyThrows
public String upload1 (@PathVariable("folder") String folder,
                       @RequestPart MultipartFile file,
                       @RequestParam(value = "message", required = false) String message
) {
  return new String(file.getBytes()) + ':' + message + ':' + folder;
}
 
源代码19 项目: swagger-aem   文件: SlingApiController.java
public ResponseEntity<String> postTruststore(@ApiParam(value = "")  @RequestParam(value = ":operation", required = false) String colonOperation,
    @ApiParam(value = "")  @RequestParam(value = "newPassword", required = false) String newPassword,
    @ApiParam(value = "")  @RequestParam(value = "rePassword", required = false) String rePassword,
    @ApiParam(value = "")  @RequestParam(value = "keyStoreType", required = false) String keyStoreType,
    @ApiParam(value = "")  @RequestParam(value = "removeAlias", required = false) String removeAlias,
    @ApiParam(value = "file detail")  @RequestPart("file") MultipartFile certificate,
    @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
    // do some magic!
    return new ResponseEntity<String>(HttpStatus.OK);
}
 
@RequestMapping(value = "/optionalfile", method = RequestMethod.POST)
public String processOptionalFile(@RequestParam Optional<MultipartFile> file,
		@RequestPart Map<String, String> json, Model model) throws IOException {

	if (file.isPresent()) {
		model.addAttribute("fileContent", file.get().getBytes());
	}
	model.addAttribute("jsonContent", json);

	return "redirect:/index";
}
 
@RequestMapping(value = "/optionalfilearray", method = RequestMethod.POST)
public String processOptionalFileArray(@RequestParam Optional<MultipartFile[]> file,
		@RequestPart Map<String, String> json, Model model) throws IOException {

	if (file.isPresent()) {
		byte[] content = file.get()[0].getBytes();
		Assert.assertArrayEquals(content, file.get()[1].getBytes());
		model.addAttribute("fileContent", content);
	}
	model.addAttribute("jsonContent", json);

	return "redirect:/index";
}
 
@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";
}
 
源代码23 项目: openapi-generator   文件: FakeApi.java
/**
 * 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);

}
 
@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();
}
 
源代码25 项目: find   文件: CustomizationAdminController.java
@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);
}
 
源代码26 项目: springdoc-openapi   文件: PetApi.java
@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);
}
 
源代码27 项目: springdoc-openapi   文件: HelloController.java
@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;
}
 
源代码28 项目: lams   文件: RequestPartMethodArgumentResolver.java
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;
}
 
源代码29 项目: openapi-generator   文件: FakeApi.java
/**
 * 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);
 
源代码30 项目: openapi-generator   文件: FakeApi.java
/**
 * 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);
 
服务器费用不足...
 类方法
支付宝打赏 微信打赏

如果文章对你有帮助,欢迎点击上方按钮打赏作者