Mercurial > hg > orthanc
changeset 6581:fa7123b2930a default tip
added ORTHANC_PLUGINS_WEBDAV_UNKNOWN_FILE_SIZE to plugin SDK
| author | Sebastien Jodogne <s.jodogne@gmail.com> |
|---|---|
| date | Tue, 27 Jan 2026 20:02:51 +0100 |
| parents | e16d84c4d0e5 |
| children | |
| files | NEWS OrthancFramework/Sources/HttpServer/IWebDavBucket.cpp OrthancFramework/Sources/HttpServer/IWebDavBucket.h OrthancServer/Plugins/Engine/OrthancPlugins.cpp OrthancServer/Plugins/Include/orthanc/OrthancCPlugin.h |
| diffstat | 5 files changed, 39 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS Tue Jan 27 17:19:25 2026 +0100 +++ b/NEWS Tue Jan 27 20:02:51 2026 +0100 @@ -21,6 +21,12 @@ now returns all resources that do not have any label attached, instead of returning all resources. This applies to the default SQLite DB and will apply to the next PostgreSQL plugin (v10.1). +Plugins +------- + +* When listing the contents of a folder in WebDAV, it is possible to use the special value + ORTHANC_PLUGINS_WEBDAV_UNKNOWN_FILE_SIZE if the file size is unknown prior to download. + Maintenance -----------
--- a/OrthancFramework/Sources/HttpServer/IWebDavBucket.cpp Tue Jan 27 17:19:25 2026 +0100 +++ b/OrthancFramework/Sources/HttpServer/IWebDavBucket.cpp Tue Jan 27 20:02:51 2026 +0100 @@ -166,12 +166,20 @@ IWebDavBucket::File::File(const std::string& displayName) : Resource(displayName), + hasContentLength_(false), contentLength_(0), mime_(MimeType_Binary) { } + void IWebDavBucket::File::SetContentLength(uint64_t contentLength) + { + hasContentLength_ = true; + contentLength_ = contentLength; + } + + void IWebDavBucket::File::Format(pugi::xml_node& node, const std::string& parentPath) const { @@ -189,11 +197,14 @@ pugi::xml_node prop = node.first_element_by_path("D:propstat/D:prop"); prop.append_child("D:resourcetype"); - std::string s = boost::lexical_cast<std::string>(contentLength_); - prop.append_child("D:getcontentlength").append_child(pugi::node_pcdata).set_value(s.c_str()); + std::string s = EnumerationToString(mime_); + prop.append_child("D:getcontenttype").append_child(pugi::node_pcdata).set_value(s.c_str()); - s = EnumerationToString(mime_); - prop.append_child("D:getcontenttype").append_child(pugi::node_pcdata).set_value(s.c_str()); + if (hasContentLength_) + { + s = boost::lexical_cast<std::string>(contentLength_); + prop.append_child("D:getcontentlength").append_child(pugi::node_pcdata).set_value(s.c_str()); + } }
--- a/OrthancFramework/Sources/HttpServer/IWebDavBucket.h Tue Jan 27 17:19:25 2026 +0100 +++ b/OrthancFramework/Sources/HttpServer/IWebDavBucket.h Tue Jan 27 20:02:51 2026 +0100 @@ -92,16 +92,14 @@ class File : public Resource { private: + bool hasContentLength_; uint64_t contentLength_; MimeType mime_; public: explicit File(const std::string& displayName); - void SetContentLength(uint64_t contentLength) - { - contentLength_ = contentLength; - } + void SetContentLength(uint64_t contentLength); void SetMimeType(MimeType mime) {
--- a/OrthancServer/Plugins/Engine/OrthancPlugins.cpp Tue Jan 27 17:19:25 2026 +0100 +++ b/OrthancServer/Plugins/Engine/OrthancPlugins.cpp Tue Jan 27 20:02:51 2026 +0100 @@ -262,7 +262,11 @@ { std::unique_ptr<File> f(new File(displayName)); f->SetCreationTime(boost::posix_time::from_iso_string(creationTime)); - f->SetContentLength(contentSize); + + if (contentSize != ORTHANC_PLUGINS_WEBDAV_UNKNOWN_FILE_SIZE) + { + f->SetContentLength(contentSize); + } if (mimeType == NULL || std::string(mimeType).empty())
--- a/OrthancServer/Plugins/Include/orthanc/OrthancCPlugin.h Tue Jan 27 17:19:25 2026 +0100 +++ b/OrthancServer/Plugins/Include/orthanc/OrthancCPlugin.h Tue Jan 27 20:02:51 2026 +0100 @@ -222,6 +222,10 @@ ** Definition of the Orthanc Plugin API. ********************************************************************/ + +#define ORTHANC_PLUGINS_WEBDAV_UNKNOWN_FILE_SIZE ((uint64_t) -1) /* New in Orthanc 1.12.11 */ + + /** @{ */ #ifdef __cplusplus @@ -9498,11 +9502,17 @@ * This function declares a file while returning the content of a * WebDAV folder. * + * Starting with Orthanc 1.12.11, if the file size is unknown + * because the file must be generated on-the-fly, you can set the + * size argument to the special value ORTHANC_PLUGINS_WEBDAV_UNKNOWN_FILE_SIZE. + * In this case, the WebDAV property "D:getcontentlength" will not be filled. + * * @param collection Context of the collection. * @param name Base name of the file. * @param dateTime The date and time of creation of the file. * Check out the documentation of OrthancPluginWebDavRetrieveFile() for more information. - * @param size Size of the file. + * @param size Size of the file. Can be set to ORTHANC_PLUGINS_WEBDAV_UNKNOWN_FILE_SIZE + * if unknown. * @param mimeType The MIME type of the file. If empty or set to `NULL`, * Orthanc will do a best guess depending on the file extension. * @return 0 if success, other value if error.
