Skip to content

Commit 1127841

Browse files
committed
Use POST method for creating new attachments instead of PUT
1 parent e66ce35 commit 1127841

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/main/java/org/tailormap/api/controller/AttachmentsController.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import java.util.Set;
1818
import java.util.UUID;
1919
import java.util.regex.Pattern;
20-
2120
import org.geotools.api.data.Query;
2221
import org.geotools.api.data.SimpleFeatureSource;
2322
import org.geotools.api.filter.Filter;
@@ -36,7 +35,7 @@
3635
import org.springframework.web.bind.annotation.GetMapping;
3736
import org.springframework.web.bind.annotation.ModelAttribute;
3837
import org.springframework.web.bind.annotation.PathVariable;
39-
import org.springframework.web.bind.annotation.PutMapping;
38+
import org.springframework.web.bind.annotation.PostMapping;
4039
import org.springframework.web.bind.annotation.RequestPart;
4140
import org.springframework.web.server.ResponseStatusException;
4241
import org.tailormap.api.annotation.AppRestController;
@@ -79,7 +78,7 @@ public AttachmentsController(EditUtil editUtil, FeatureSourceFactoryHelper featu
7978
* @param fileData the attachment file data
8079
* @return the response entity
8180
*/
82-
@PutMapping(
81+
@PostMapping(
8382
path = {
8483
"${tailormap-api.base-path}/{viewerKind}/{viewerName}/layer/{appLayerId}/feature/{featureId}/attachments"
8584
},
@@ -151,7 +150,8 @@ public ResponseEntity<Serializable> addAttachment(
151150
* @return true if the file's extension or MIME type matches one of the accepted types, false otherwise
152151
*/
153152
private static boolean validateMimeTypeAccept(String acceptList, String fileName, String mimeType) {
154-
Iterable<String> allowedMimeTypes = Splitter.on(Pattern.compile(",\\s*")).split(acceptList);
153+
Iterable<String> allowedMimeTypes =
154+
Splitter.on(Pattern.compile(",\\s*")).split(acceptList);
155155
final Locale locale = Locale.ENGLISH;
156156
for (String allowedType : allowedMimeTypes) {
157157
if (allowedType.startsWith(".")) {

src/test/java/org/tailormap/api/controller/AttachmentsControllerIntegrationTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ void addAttachment(String url) throws Exception {
120120
.file(attachmentMetadata)
121121
.file(svgFile)
122122
.with(request -> {
123-
request.setMethod("PUT");
123+
request.setMethod("POST");
124124
return request;
125125
})
126126
.with(setServletPath(url))
@@ -150,7 +150,7 @@ void addAttachmentUnauthorised(String url) throws Exception {
150150
.file(attachmentMetadata)
151151
.file(svgFile)
152152
.with(request -> {
153-
request.setMethod("PUT");
153+
request.setMethod("POST");
154154
return request;
155155
})
156156
.with(setServletPath(url))
@@ -174,7 +174,7 @@ void addAttachmentsNotSupported() throws Exception {
174174
.file(attachmentMetadata)
175175
.file(svgFile)
176176
.with(request -> {
177-
request.setMethod("PUT");
177+
request.setMethod("POST");
178178
return request;
179179
})
180180
.with(setServletPath(url))
@@ -200,7 +200,7 @@ void addAttachmentsToNonEditableLayer() throws Exception {
200200
.file(attachmentMetadata)
201201
.file(svgFile)
202202
.with(request -> {
203-
request.setMethod("PUT");
203+
request.setMethod("POST");
204204
return request;
205205
})
206206
.with(setServletPath(url))

0 commit comments

Comments
 (0)