Skip to content

Commit ec91934

Browse files
committed
Use correct file options for transferTo
Similar to fix applied to Synchronoss implementation in #cef98e.
1 parent 1259b7c commit ec91934

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

spring-web/src/main/java/org/springframework/http/codec/multipart/DefaultMultipartMessageReader.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.nio.channels.Channel;
2222
import java.nio.charset.Charset;
2323
import java.nio.charset.StandardCharsets;
24+
import java.nio.file.OpenOption;
2425
import java.nio.file.Path;
2526
import java.nio.file.StandardOpenOption;
2627
import java.util.Collections;
@@ -367,6 +368,10 @@ public String value() {
367368

368369
private static class DefaultFilePart extends DefaultPart implements FilePart {
369370

371+
private static final OpenOption[] FILE_CHANNEL_OPTIONS =
372+
{StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE};
373+
374+
370375
public DefaultFilePart(HttpHeaders headers, DataBuffer body) {
371376
super(headers, body);
372377
}
@@ -380,7 +385,7 @@ public String filename() {
380385

381386
@Override
382387
public Mono<Void> transferTo(Path dest) {
383-
return Mono.using(() -> AsynchronousFileChannel.open(dest, StandardOpenOption.WRITE),
388+
return Mono.using(() -> AsynchronousFileChannel.open(dest, FILE_CHANNEL_OPTIONS),
384389
this::writeBody, this::close);
385390
}
386391

0 commit comments

Comments
 (0)