|
@@ -32,6 +32,7 @@ import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.io.OutputStream;
|
|
|
import java.nio.file.DirectoryStream;
|
|
|
+import java.nio.file.FileAlreadyExistsException;
|
|
|
import java.nio.file.Files;
|
|
|
import java.nio.file.NoSuchFileException;
|
|
|
import java.nio.file.Path;
|
|
@@ -108,6 +109,9 @@ public class FsBlobContainer extends AbstractBlobContainer {
|
|
|
|
|
|
@Override
|
|
|
public void writeBlob(String blobName, InputStream inputStream, long blobSize) throws IOException {
|
|
|
+ if (blobExists(blobName)) {
|
|
|
+ throw new FileAlreadyExistsException("blob [" + blobName + "] already exists, cannot overwrite");
|
|
|
+ }
|
|
|
final Path file = path.resolve(blobName);
|
|
|
try (OutputStream outputStream = Files.newOutputStream(file, StandardOpenOption.CREATE_NEW)) {
|
|
|
Streams.copy(inputStream, outputStream, new byte[blobStore.bufferSizeInBytes()]);
|