Hi @Pegah,
Something like the following:
# Setup
image_id = SOMETHING_HERE
client = MUST_BE_DEFINED
import os
from omero.rtypes import unwrap
resources = client.sf.sharedResources()
repos = resources.repositories()
for desc in repos.descriptions:
if desc.name.val == "ManagedRepository":
managed_repo_dir = desc.path.val + desc.name.val
params = omero.sys.ParametersI()
params.addId(image_id)
rows = client.sf.getQueryService().projection("""
SELECT DISTINCT ofile.id, ofile.path
|| ofile.name FROM Image AS i
JOIN i.fileset AS f
JOIN f.usedFiles AS fe
JOIN fe.originalFile AS ofile
WHERE i.id = :id""", params, {"omero.group": "-1"})
imported_file = os.path.join(managed_repo_dir, unwrap(rows[0][1]))
should give you the path to the first imported file for an image.
Heads up for anyone using this code: Since only a user who should have permissions to access the image should be allowed to run this code, it is safe as written. Be careful though to not introduce a backdoor into your /OMERO/ManagedRepository!
~Josh