Mercurial > hg > orthanc
comparison OrthancServer/ServerContext.cpp @ 699:2929e17f8447
add attachments to resources
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 05 Feb 2014 17:49:30 +0100 |
parents | dd1ce9a2844c |
children | 309e686b41e7 |
comparison
equal
deleted
inserted
replaced
698:aae83e1e31f7 | 699:2929e17f8447 |
---|---|
282 { | 282 { |
283 LOG(INFO) << "Storing MD5 for attachments: " << (storeMD5 ? "yes" : "no"); | 283 LOG(INFO) << "Storing MD5 for attachments: " << (storeMD5 ? "yes" : "no"); |
284 accessor_.SetStoreMD5(storeMD5); | 284 accessor_.SetStoreMD5(storeMD5); |
285 } | 285 } |
286 | 286 |
287 | |
288 bool ServerContext::AddAttachment(const std::string& resourceId, | |
289 FileContentType attachmentType, | |
290 const void* data, | |
291 size_t size) | |
292 { | |
293 LOG(INFO) << "Adding attachment " << EnumerationToString(attachmentType) << " to resource " << resourceId; | |
294 | |
295 if (compressionEnabled_) | |
296 { | |
297 accessor_.SetCompressionForNextOperations(CompressionType_Zlib); | |
298 } | |
299 else | |
300 { | |
301 accessor_.SetCompressionForNextOperations(CompressionType_None); | |
302 } | |
303 | |
304 FileInfo info = accessor_.Write(data, size, attachmentType); | |
305 StoreStatus status = index_.AddAttachment(info, resourceId); | |
306 | |
307 if (status != StoreStatus_Success) | |
308 { | |
309 storage_.Remove(info.GetUuid()); | |
310 return false; | |
311 } | |
312 else | |
313 { | |
314 return true; | |
315 } | |
316 } | |
287 } | 317 } |