Skip to content

Commit e4bb147

Browse files
authored
Merge pull request #51 from TP-RENTPLACE/feature/(TP-124)-increase-max-request-size
Feature/(tp 124) increase max request size
2 parents 95d2249 + b46bc82 commit e4bb147

4 files changed

Lines changed: 3 additions & 60 deletions

File tree

rentplace/src/main/java/kattsyn/dev/rentplace/controllers/ImageController.java

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
1010
import io.swagger.v3.oas.annotations.tags.Tag;
1111
import kattsyn.dev.rentplace.entities.Image;
12-
import kattsyn.dev.rentplace.enums.ImageType;
1312
import kattsyn.dev.rentplace.services.ImageService;
1413
import lombok.extern.slf4j.Slf4j;
1514
import org.springframework.beans.factory.annotation.Value;
@@ -20,14 +19,11 @@
2019
import org.springframework.http.ResponseEntity;
2120
import org.springframework.security.access.prepost.PreAuthorize;
2221
import org.springframework.web.bind.annotation.*;
23-
import org.springframework.web.multipart.MultipartFile;
2422

2523
import java.io.IOException;
2624
import java.nio.file.Files;
2725
import java.nio.file.Path;
2826
import java.nio.file.Paths;
29-
import java.util.ArrayList;
30-
import java.util.List;
3127

3228
@RestController
3329
@RequestMapping("${api.path}/images")
@@ -70,59 +66,6 @@ public ResponseEntity<Resource> getImage(
7066
}
7167
}
7268

73-
@Operation(
74-
summary = "Загрузка фотографии",
75-
description = "Загрузка фотографии"
76-
)
77-
@ApiResponses(value = {
78-
@ApiResponse(responseCode = "200", description = "Успешно", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Image.class))),
79-
@ApiResponse(responseCode = "500", description = "Непредвиденная ошибка со стороны сервера", content = @Content)
80-
})
81-
@SecurityRequirement(name = "JWT")
82-
@PreAuthorize("hasAuthority('ROLE_ADMIN')")
83-
@PostMapping(path = "/", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
84-
public ResponseEntity<Image> uploadImage(
85-
@Parameter(
86-
description = "Файл фотографии",
87-
required = true,
88-
content = @Content(mediaType = MediaType.MULTIPART_FORM_DATA_VALUE)
89-
) @RequestParam("file") MultipartFile file,
90-
@Parameter(
91-
description = "Тип изображения",
92-
required = true,
93-
schema = @Schema(
94-
implementation = ImageType.class)
95-
) @RequestParam ImageType imageType) { //todo: delete method
96-
return ResponseEntity.ok(imageService.uploadImage(file, imageType));
97-
}
98-
99-
100-
101-
@PostMapping(value = "/multiple/", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
102-
@Operation(
103-
summary = "Массовая загрузка фотографий",
104-
description = "Загружает несколько фотографий за один запрос. Максимальное количество файлов - 10. Максимальный размер каждого файла - 10MB.")
105-
@ApiResponses(value = {
106-
@ApiResponse(responseCode = "200", description = "Фотографии успешно загружены", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Image[].class))),
107-
@ApiResponse(responseCode = "400", description = "Некорректный запрос (превышено кол-во файлов, неверный формат и т.д.)", content = @Content),
108-
@ApiResponse(responseCode = "413", description = "Превышен максимальный размер запроса"),
109-
@ApiResponse(responseCode = "500", description = "Внутренняя ошибка сервера")
110-
})
111-
@SecurityRequirement(name = "JWT")
112-
@PreAuthorize("hasAuthority('ROLE_ADMIN')")
113-
public ResponseEntity<List<Image>> uploadMultipleImages(@Parameter(
114-
description = "Массив файлов фотографий",
115-
required = true,
116-
content = @Content(mediaType = MediaType.MULTIPART_FORM_DATA_VALUE, schema = @Schema(type = "string", format = "binary"))
117-
) @RequestPart("files") MultipartFile[] files) {
118-
List<Image> savedImages = new ArrayList<>();
119-
120-
for (MultipartFile file : files) {
121-
savedImages.add(imageService.uploadImage(file));
122-
}
123-
124-
return ResponseEntity.ok(savedImages);
125-
}
12669

12770
@Operation(
12871
summary = "Получить фотографию",

rentplace/src/main/java/kattsyn/dev/rentplace/controllers/PropertyController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class PropertyController {
3838
@PostMapping(value = "/{id}/images", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
3939
@Operation(
4040
summary = "Массовая загрузка фотографий",
41-
description = "Загружает несколько фотографий за один запрос. Максимальное количество файлов - 10. Максимальный размер каждого файла - 10MB.")
41+
description = "Загружает несколько фотографий за один запрос. Максимальное количество файлов - 20. Максимальный размер каждого файла - 5MB.")
4242
@ApiResponses(value = {
4343
@ApiResponse(responseCode = "200", description = "Фотографии успешно загружены", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ImageDTO[].class))),
4444
@ApiResponse(responseCode = "400", description = "Некорректный запрос (превышено кол-во файлов, неверный формат и т.д.)", content = @Content),

rentplace/src/main/java/kattsyn/dev/rentplace/controllers/UserController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class UserController {
3636

3737
@Operation(
3838
summary = "Загрузка фотографии для пользователя",
39-
description = "Загрузка фотографии для пользователя"
39+
description = "Загрузка фотографии для пользователя. Размер фотографии до 5Мб"
4040
)
4141
@ApiResponses(value = {
4242
@ApiResponse(responseCode = "200", description = "Успешно", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Image.class))),

rentplace/src/main/resources/application.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ spring:
22
servlet:
33
multipart:
44
max-file-size: 5MB
5-
max-request-size: 10MB
5+
max-request-size: 120MB
66
application:
77
name: rentplace
88
datasource:

0 commit comments

Comments
 (0)