Use path/directory/file name instead of path. (#1398)

* Use path/directory/file name instead of path.

* Resolved review comments and refined docs.
This commit is contained in:
Kan Tang 2021-01-20 12:08:42 +08:00 committed by GitHub
parent 6bd4ded77f
commit d0abaa1076
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 30 additions and 29 deletions

View File

@ -25,14 +25,14 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
* @brief Create from connection string
* @param connectionString Azure Storage connection string.
* @param fileSystemName The name of a file system.
* @param directoryPath The path of a directory within the file system.
* @param directoryName The name of a directory within the file system.
* @param options Optional parameters used to initialize the client.
* @return DataLakeDirectoryClient
*/
static DataLakeDirectoryClient CreateFromConnectionString(
const std::string& connectionString,
const std::string& fileSystemName,
const std::string& directoryPath,
const std::string& directoryName,
const DataLakeClientOptions& options = DataLakeClientOptions());
/**
@ -68,17 +68,17 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
/**
* @brief Create a FileClient from current DataLakeDirectoryClient
* @param path Path of the file under the directory.
* @param fileName Name of the file under the directory.
* @return FileClient
*/
DataLakeFileClient GetFileClient(const std::string& path) const;
DataLakeFileClient GetFileClient(const std::string& fileName) const;
/**
* @brief Create a DataLakeDirectoryClient from current DataLakeDirectoryClient
* @param path Path of the directory under the current directory.
* @param subdirectoryName Name of the directory under the current directory.
* @return DataLakeDirectoryClient
*/
DataLakeDirectoryClient GetSubdirectoryClient(const std::string& path) const;
DataLakeDirectoryClient GetSubdirectoryClient(const std::string& subdirectoryName) const;
/**
* @brief Gets the directory's primary uri endpoint. This is the endpoint used for blob

View File

@ -26,14 +26,14 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
* @brief Create from connection string
* @param connectionString Azure Storage connection string.
* @param fileSystemName The name of a file system.
* @param filePath The path of a file within the file system.
* @param fileName The name of a file within the file system.
* @param options Optional parameters used to initialize the client.
* @return DataLakeFileClient
*/
static DataLakeFileClient CreateFromConnectionString(
const std::string& connectionString,
const std::string& fileSystemName,
const std::string& filePath,
const std::string& fileName,
const DataLakeClientOptions& options = DataLakeClientOptions());
/**

View File

@ -70,24 +70,24 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
/**
* @brief Create a DataLakePathClient from current DataLakeFileSystemClient
* @param path Path of the resource within the file system.
* @param path Name of path within the file system.
* @return DataLakePathClient
*/
DataLakePathClient GetPathClient(const std::string& path) const;
/**
* @brief Create a DataLakeFileClient from current DataLakeFileSystemClient
* @param path Path of the file within the file system.
* @param fileName Name of the file within the file system.
* @return DataLakeFileClient
*/
DataLakeFileClient GetFileClient(const std::string& path) const;
DataLakeFileClient GetFileClient(const std::string& fileName) const;
/**
* @brief Create a DataLakeDirectoryClient from current DataLakeFileSystemClient
* @param path Path of the directory within the file system.
* @param directoryName Name of the directory within the file system.
* @return DataLakeDirectoryClient
*/
DataLakeDirectoryClient GetDirectoryClient(const std::string& path) const;
DataLakeDirectoryClient GetDirectoryClient(const std::string& directoryName) const;
/**
* @brief Gets the filesystem's primary uri endpoint. This is the endpoint used for blob

View File

@ -20,13 +20,13 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
DataLakeDirectoryClient DataLakeDirectoryClient::CreateFromConnectionString(
const std::string& connectionString,
const std::string& fileSystemName,
const std::string& path,
const std::string& directoryName,
const DataLakeClientOptions& options)
{
auto parsedConnectionString = Azure::Storage::Details::ParseConnectionString(connectionString);
auto directoryUri = std::move(parsedConnectionString.DataLakeServiceUrl);
directoryUri.AppendPath(Storage::Details::UrlEncodePath(fileSystemName));
directoryUri.AppendPath(Storage::Details::UrlEncodePath(path));
directoryUri.AppendPath(Storage::Details::UrlEncodePath(directoryName));
if (parsedConnectionString.KeyCredential)
{
@ -126,24 +126,24 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
m_pipeline = std::make_shared<Azure::Core::Http::HttpPipeline>(policies);
}
DataLakeFileClient DataLakeDirectoryClient::GetFileClient(const std::string& path) const
DataLakeFileClient DataLakeDirectoryClient::GetFileClient(const std::string& fileName) const
{
auto builder = m_dfsUri;
builder.AppendPath(Storage::Details::UrlEncodePath(path));
builder.AppendPath(Storage::Details::UrlEncodePath(fileName));
auto blobClient = m_blobClient;
blobClient.m_blobUrl.AppendPath(Storage::Details::UrlEncodePath(path));
blobClient.m_blobUrl.AppendPath(Storage::Details::UrlEncodePath(fileName));
auto blockBlobClient = blobClient.AsBlockBlobClient();
return DataLakeFileClient(
std::move(builder), std::move(blobClient), std::move(blockBlobClient), m_pipeline);
}
DataLakeDirectoryClient DataLakeDirectoryClient::GetSubdirectoryClient(
const std::string& path) const
const std::string& subdirectoryName) const
{
auto builder = m_dfsUri;
builder.AppendPath(Storage::Details::UrlEncodePath(path));
builder.AppendPath(Storage::Details::UrlEncodePath(subdirectoryName));
auto blobClient = m_blobClient;
blobClient.m_blobUrl.AppendPath(Storage::Details::UrlEncodePath(path));
blobClient.m_blobUrl.AppendPath(Storage::Details::UrlEncodePath(subdirectoryName));
return DataLakeDirectoryClient(std::move(builder), std::move(blobClient), m_pipeline);
}

View File

@ -87,13 +87,13 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
DataLakeFileClient DataLakeFileClient::CreateFromConnectionString(
const std::string& connectionString,
const std::string& fileSystemName,
const std::string& filePath,
const std::string& fileName,
const DataLakeClientOptions& options)
{
auto parsedConnectionString = Azure::Storage::Details::ParseConnectionString(connectionString);
auto fileUri = std::move(parsedConnectionString.DataLakeServiceUrl);
fileUri.AppendPath(Storage::Details::UrlEncodePath(fileSystemName));
fileUri.AppendPath(Storage::Details::UrlEncodePath(filePath));
fileUri.AppendPath(Storage::Details::UrlEncodePath(fileName));
if (parsedConnectionString.KeyCredential)
{

View File

@ -167,23 +167,24 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
return DataLakePathClient(builder, m_blobContainerClient.GetBlobClient(path), m_pipeline);
}
DataLakeFileClient DataLakeFileSystemClient::GetFileClient(const std::string& path) const
DataLakeFileClient DataLakeFileSystemClient::GetFileClient(const std::string& fileName) const
{
auto builder = m_dfsUri;
builder.AppendPath(Storage::Details::UrlEncodePath(path));
auto blobClient = m_blobContainerClient.GetBlobClient(path);
builder.AppendPath(Storage::Details::UrlEncodePath(fileName));
auto blobClient = m_blobContainerClient.GetBlobClient(fileName);
auto blockBlobClient = blobClient.AsBlockBlobClient();
return DataLakeFileClient(
std::move(builder), std::move(blobClient), std::move(blockBlobClient), m_pipeline);
}
DataLakeDirectoryClient DataLakeFileSystemClient::GetDirectoryClient(
const std::string& path) const
const std::string& directoryName) const
{
auto builder = m_dfsUri;
builder.AppendPath(Storage::Details::UrlEncodePath(path));
return DataLakeDirectoryClient(builder, m_blobContainerClient.GetBlobClient(path), m_pipeline);
builder.AppendPath(Storage::Details::UrlEncodePath(directoryName));
return DataLakeDirectoryClient(
builder, m_blobContainerClient.GetBlobClient(directoryName), m_pipeline);
}
Azure::Core::Response<Models::CreateDataLakeFileSystemResult> DataLakeFileSystemClient::Create(