Add interfaces for accessing content of attachments. (#274)

This commit is contained in:
An Tao 2019-10-08 15:46:48 +08:00 committed by GitHub
parent c9076220ac
commit df82728a45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 4 deletions

View File

@ -70,13 +70,33 @@ class HttpFile
int saveAs(const std::string &filename) const;
/// Return the file length.
int64_t fileLength() const
int64_t fileLength() const noexcept
{
return _fileContent.length();
};
/// Return the file content.
char *fileData() noexcept
{
#if __cplusplus >= 201703L
return _fileContent.data();
#else
return (char *)(_fileContent.data());
#endif
}
const char *fileData() const noexcept
{
return _fileContent.data();
}
std::string &fileContent() noexcept
{
return _fileContent;
}
const std::string &fileContent() const noexcept
{
return _fileContent;
}
/// Return the md5 string of the file
const std::string getMd5() const;
std::string getMd5() const;
protected:
int saveTo(const std::string &pathAndFilename) const;

View File

@ -222,7 +222,7 @@ int HttpFile::saveTo(const std::string &pathAndFilename) const
return -1;
}
}
const std::string HttpFile::getMd5() const
std::string HttpFile::getMd5() const
{
#ifdef OpenSSL_FOUND
MD5_CTX c;