Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import com.azure.storage.blob.BlobClientBuilder;
import com.azure.storage.blob.BlobContainerAsyncClient;
import com.azure.storage.blob.BlobContainerClientBuilder;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
Expand Down Expand Up @@ -284,8 +286,10 @@ public Mono<FolderDatasetVersion> createDatasetWithFolder(String name, String ve
String relativePath = folderPath.relativize(filePath).toString().replace('\\', '/');
return containerClient.getBlobAsyncClient(relativePath).upload(BinaryData.fromFile(filePath), true);
}).then(Mono.just(containerUrl));
} catch (Exception e) {
return Mono.error(new RuntimeException("Error walking through folder path", e));
} catch (IOException e) {
return Mono.error(new UncheckedIOException("Failed to walk folder path: " + folderPath, e));
} catch (RuntimeException e) {
return Mono.error(e);
Comment thread
kaylieee marked this conversation as resolved.
}
}).flatMap(containerUrl -> {
RequestOptions requestOptions = new RequestOptions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.azure.storage.blob.BlobContainerClient;
import com.azure.storage.blob.BlobContainerClientBuilder;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.stream.Stream;
Expand Down Expand Up @@ -226,11 +227,10 @@ public FileDatasetVersion createDatasetWithFile(String name, String version, Pat
* @param folderPath The path to the folder containing files to upload.
* @return A FolderDatasetVersion representing the created dataset.
* @throws IllegalArgumentException If the provided path is not a directory.
* @throws IOException if an I/ O error is thrown when accessing the starting file
* @throws UncheckedIOException if an I/ O error is thrown when accessing the starting file
Comment thread
kaylieee marked this conversation as resolved.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public FolderDatasetVersion createDatasetWithFolder(String name, String version, Path folderPath)
throws IOException {
public FolderDatasetVersion createDatasetWithFolder(String name, String version, Path folderPath) {
return createDatasetWithFolder(name, version, folderPath, null);
}

Expand All @@ -244,11 +244,11 @@ public FolderDatasetVersion createDatasetWithFolder(String name, String version,
* If null, the default Azure Storage Account connection will be used.
* @return A FolderDatasetVersion representing the created dataset.
* @throws IllegalArgumentException If the provided path is not a directory.
* @throws IOException if an I/O error is thrown when accessing the starting file
* @throws UncheckedIOException if an I/O error is thrown when accessing the starting file
*/
Comment thread
kaylieee marked this conversation as resolved.
@ServiceMethod(returns = ReturnType.SINGLE)
public FolderDatasetVersion createDatasetWithFolder(String name, String version, Path folderPath,
String connectionName) throws IOException {
String connectionName) {
Comment thread
kaylieee marked this conversation as resolved.
if (!Files.isDirectory(folderPath)) {
throw LOGGER
.logExceptionAsError(new IllegalArgumentException("The provided path is not a folder: " + folderPath));
Expand All @@ -268,6 +268,8 @@ public FolderDatasetVersion createDatasetWithFolder(String name, String version,
String relativePath = folderPath.relativize(filePath).toString().replace('\\', '/');
containerClient.getBlobClient(relativePath).upload(BinaryData.fromFile(filePath), true);
});
} catch (IOException e) {
throw LOGGER.logExceptionAsError(new UncheckedIOException("Failed to walk folder path: " + folderPath, e));
}
RequestOptions requestOptions = new RequestOptions();
FolderDatasetVersion datasetVersion = this
Expand Down
Loading