本文整理汇总了C++中FileInfo::GetContentType方法的典型用法代码示例。如果您正苦于以下问题:C++ FileInfo::GetContentType方法的具体用法?C++ FileInfo::GetContentType怎么用?C++ FileInfo::GetContentType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileInfo
的用法示例。
在下文中一共展示了FileInfo::GetContentType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddAttachment
bool ServerContext::AddAttachment(const std::string& resourceId,
FileContentType attachmentType,
const void* data,
size_t size)
{
LOG(INFO) << "Adding attachment " << EnumerationToString(attachmentType) << " to resource " << resourceId;
if (compressionEnabled_)
{
accessor_.SetCompressionForNextOperations(CompressionType_Zlib);
}
else
{
accessor_.SetCompressionForNextOperations(CompressionType_None);
}
FileInfo info = accessor_.Write(data, size, attachmentType);
StoreStatus status = index_.AddAttachment(info, resourceId);
if (status != StoreStatus_Success)
{
accessor_.Remove(info.GetUuid(), info.GetContentType());
return false;
}
else
{
return true;
}
}
示例2: AddAttachment
void DatabaseWrapperBase::AddAttachment(int64_t id,
const FileInfo& attachment)
{
SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO AttachedFiles VALUES(?, ?, ?, ?, ?, ?, ?, ?)");
s.BindInt64(0, id);
s.BindInt(1, attachment.GetContentType());
s.BindString(2, attachment.GetUuid());
s.BindInt64(3, attachment.GetCompressedSize());
s.BindInt64(4, attachment.GetUncompressedSize());
s.BindInt(5, attachment.GetCompressionType());
s.BindString(6, attachment.GetUncompressedMD5());
s.BindString(7, attachment.GetCompressedMD5());
s.Run();
}
示例3: s
TEST(StorageAccessor, Compression)
{
FilesystemStorage s("UnitTestsStorage");
StorageAccessor accessor(s);
std::string data = "Hello world";
FileInfo info = accessor.Write(data, FileContentType_DicomAsJson, CompressionType_ZlibWithSize, true);
std::string r;
accessor.Read(r, info);
ASSERT_EQ(data, r);
ASSERT_EQ(CompressionType_ZlibWithSize, info.GetCompressionType());
ASSERT_EQ(11u, info.GetUncompressedSize());
ASSERT_EQ(FileContentType_DicomAsJson, info.GetContentType());
ASSERT_EQ("3e25960a79dbc69b674cd4ec67a72c62", info.GetUncompressedMD5());
ASSERT_NE(info.GetUncompressedMD5(), info.GetCompressedMD5());
}
示例4: ReadFile
void ServerContext::ReadFile(std::string& result,
const std::string& instancePublicId,
FileContentType content,
bool uncompressIfNeeded)
{
FileInfo attachment;
if (!index_.LookupAttachment(attachment, instancePublicId, content))
{
throw OrthancException(ErrorCode_InternalError);
}
if (uncompressIfNeeded)
{
accessor_.SetCompressionForNextOperations(attachment.GetCompressionType());
}
else
{
accessor_.SetCompressionForNextOperations(CompressionType_None);
}
accessor_.Read(result, attachment.GetUuid(), attachment.GetContentType());
}
示例5: AnswerAttachment
void ServerContext::AnswerAttachment(RestApiOutput& output,
const std::string& instancePublicId,
FileContentType content)
{
FileInfo attachment;
if (!index_.LookupAttachment(attachment, instancePublicId, content))
{
throw OrthancException(ErrorCode_InternalError);
}
accessor_.SetCompressionForNextOperations(attachment.GetCompressionType());
std::auto_ptr<HttpFileSender> sender(accessor_.ConstructHttpFileSender(attachment.GetUuid(), attachment.GetContentType()));
sender->SetContentType(GetMimeType(content));
sender->SetDownloadFilename(instancePublicId + ".dcm");
output.AnswerFile(*sender);
}