Use correct file options for transferTo

Similar to fix applied to Synchronoss implementation in #cef98e.
This commit is contained in:
Rossen Stoyanchev
2019-06-05 10:54:56 -04:00
parent 1259b7cb49
commit ec91934730

View File

@@ -21,6 +21,7 @@ import java.nio.channels.AsynchronousFileChannel;
import java.nio.channels.Channel;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.OpenOption;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.Collections;
@@ -367,6 +368,10 @@ public class DefaultMultipartMessageReader extends LoggingCodecSupport implement
private static class DefaultFilePart extends DefaultPart implements FilePart {
private static final OpenOption[] FILE_CHANNEL_OPTIONS =
{StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE};
public DefaultFilePart(HttpHeaders headers, DataBuffer body) {
super(headers, body);
}
@@ -380,7 +385,7 @@ public class DefaultMultipartMessageReader extends LoggingCodecSupport implement
@Override
public Mono<Void> transferTo(Path dest) {
return Mono.using(() -> AsynchronousFileChannel.open(dest, StandardOpenOption.WRITE),
return Mono.using(() -> AsynchronousFileChannel.open(dest, FILE_CHANNEL_OPTIONS),
this::writeBody, this::close);
}