Migrate to java.nio.file.createTempFile (#3767)

Use function from nio package as it uses more restrictive file permissions.

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
This commit is contained in:
Holger Friedrich 2023-08-26 15:08:03 +02:00 committed by GitHub
parent 7743e9f9ab
commit ce5cef959b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,6 +17,7 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.nio.file.Files;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -297,7 +298,7 @@ public class AudioServlet extends HttpServlet implements AudioHTTPServer {
clonableAudioStreamResult = new ByteArrayAudioStream(dataBytes, stream.getFormat()); clonableAudioStreamResult = new ByteArrayAudioStream(dataBytes, stream.getFormat());
} else { } else {
// in memory max size exceeded, sound is too long, we will use a file // in memory max size exceeded, sound is too long, we will use a file
File tempFile = File.createTempFile(streamId, ".snd"); File tempFile = Files.createTempFile(streamId, ".snd").toFile();
tempFile.deleteOnExit(); tempFile.deleteOnExit();
try (OutputStream outputStream = new FileOutputStream(tempFile)) { try (OutputStream outputStream = new FileOutputStream(tempFile)) {
// copy already read data to file : // copy already read data to file :