remove Base64EncodeText (#1307)

This commit is contained in:
JinmingHu 2021-01-11 14:34:29 +08:00 committed by GitHub
parent f935477e66
commit abc2ec2943
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 18 additions and 16 deletions

View File

@ -139,7 +139,7 @@ namespace Azure { namespace Storage { namespace Blobs {
constexpr std::size_t BlockIdLength = 64;
std::string blockId = std::to_string(id);
blockId = std::string(BlockIdLength - blockId.length(), '0') + blockId;
return Internal::Base64EncodeText(blockId);
return Azure::Core::Base64Encode(std::vector<uint8_t>(blockId.begin(), blockId.end()));
};
auto uploadBlockFunc = [&](int64_t offset, int64_t length, int64_t chunkId, int64_t numChunks) {
@ -220,7 +220,7 @@ namespace Azure { namespace Storage { namespace Blobs {
constexpr std::size_t BlockIdLength = 64;
std::string blockId = std::to_string(id);
blockId = std::string(BlockIdLength - blockId.length(), '0') + blockId;
return Internal::Base64EncodeText(blockId);
return Azure::Core::Base64Encode(std::vector<uint8_t>(blockId.begin(), blockId.end()));
};
auto uploadBlockFunc = [&](int64_t offset, int64_t length, int64_t chunkId, int64_t numChunks) {

View File

@ -544,8 +544,8 @@ namespace Azure { namespace Storage { namespace Test {
auto blockBlob = containerClient.GetBlockBlobClient(blockBlobName);
bodyStream.Rewind();
EXPECT_NO_THROW(blockBlob.Upload(&bodyStream));
std::string blockId1 = Internal::Base64EncodeText("1");
std::string blockId2 = Internal::Base64EncodeText("2");
std::string blockId1 = Base64EncodeText("1");
std::string blockId2 = Base64EncodeText("2");
bodyStream.Rewind();
EXPECT_NO_THROW(blockBlob.StageBlock(blockId1, &bodyStream));
EXPECT_NO_THROW(blockBlob.StageBlockFromUri(blockId2, copySourceBlob.GetUrl() + GetSas()));
@ -1045,7 +1045,7 @@ namespace Azure { namespace Storage { namespace Test {
}
{
std::string blockId = Internal::Base64EncodeText("1");
std::string blockId = Base64EncodeText("1");
std::vector<std::string> blockIds = {blockId};
content.Rewind();
blockBlobClient.StageBlock(blockId, &content);

View File

@ -269,8 +269,8 @@ namespace Azure { namespace Storage { namespace Test {
TEST_F(BlockBlobClientTest, StageBlock)
{
const std::string blockId1 = Azure::Storage::Internal::Base64EncodeText("0");
const std::string blockId2 = Azure::Storage::Internal::Base64EncodeText("1");
const std::string blockId1 = Base64EncodeText("0");
const std::string blockId2 = Base64EncodeText("1");
auto blockBlobClient = Azure::Storage::Blobs::BlockBlobClient::CreateFromConnectionString(
StandardStorageConnectionString(), m_containerName, RandomString());
std::vector<uint8_t> block1Content;

View File

@ -16,7 +16,7 @@
- All date time related strings are now changed to `Azure::Core::DateTime` type.
- Move version strings into `Details` namespace.
- Move `Base64Encode` and `Base64Decode` from the `Azure::Storage` namespace to `Azure::Core`.
- Rename the string accepting overload of `Base64Encode` to `Base64EncodeText` and make it internal by moving it to the `Azure::Storage::Internal` namespace.
- Remove the string accepting overload of `Base64Encode`.
## 12.0.0-beta.5 (2020-11-13)

View File

@ -11,13 +11,6 @@
namespace Azure { namespace Storage {
namespace Internal {
inline std::string Base64EncodeText(const std::string& text)
{
return Azure::Core::Base64Encode(std::vector<uint8_t>(text.begin(), text.end()));
}
} // namespace Internal
class Md5 {
public:
Md5();

View File

@ -8,6 +8,7 @@
#include <limits>
#include <vector>
#include <azure/core/base64.hpp>
#include <azure/core/datetime.hpp>
#include <azure/core/http/body_stream.hpp>
#include <azure/storage/common/constants.hpp>
@ -83,4 +84,9 @@ namespace Azure { namespace Storage { namespace Test {
bool IsValidTime(const Azure::Core::DateTime& datetime);
inline std::string Base64EncodeText(const std::string& text)
{
return Azure::Core::Base64Encode(std::vector<uint8_t>(text.begin(), text.end()));
}
}}} // namespace Azure::Storage::Test

View File

@ -39,7 +39,10 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { nam
std::string result;
for (const auto& pair : dataLakePropertiesMap)
{
result.append(pair.first + "=" + Internal::Base64EncodeText(pair.second) + ",");
result.append(
pair.first + "="
+ Azure::Core::Base64Encode(std::vector<uint8_t>(pair.second.begin(), pair.second.end()))
+ ",");
}
if (!result.empty())
{