view Sphinx/source/plugins/python/storage-area.py @ 840:1262a26f96d1

Added tag Orthanc-1.11.0 for changeset c29ac12e3160
author Alain Mazy <am@osimis.io>
date Mon, 09 May 2022 13:11:47 +0200
parents a296fe06fd86
children
line wrap: on
line source

import orthanc
import os

def GetPath(uuid, contentType):
    # Returns the path where to store the given attachment
    return 'attachment-%d-%s' % (contentType, uuid)

def OnCreate(uuid, contentType, data):
    with open(GetPath(uuid, contentType), 'wb') as f:
        f.write(data)

def OnRead(uuid, contentType):
    with open(GetPath(uuid, contentType), 'rb') as f:
        return f.read()

def OnRemove(uuid, contentType):
    os.remove(GetPath(uuid, contentType))

orthanc.RegisterStorageArea(OnCreate, OnRead, OnRemove)