We're Hiring!

Archived original files

General and open developer discussion about using OMERO APIs from C++, Java, Python, Matlab and more! Please new questions at https://forum.image.sc/tags/omero
Please note:
Historical discussions about OMERO. Please look for and ask new questions at https://forum.image.sc/tags/omero

If you are having trouble with custom code, please provide a link to a public repository, ideally GitHub.

Archived original files

Postby johnjhufnagle » Mon May 24, 2010 3:54 pm


If the user, at import time, chooses the "Archive the original imported files(s) to the server" option, is there a way through the API to get those files either as bytes or perhaps the file path(s) that the client app can then access through the file system?

Posts: 34
Joined: Tue Dec 15, 2009 8:50 pm

Re: Archived original files

Postby jburel » Thu May 27, 2010 2:15 pm

Hi John
If the user selects the archived option, to retrieve the files you can do:
Use the Query service to retrieve the original files linked to a given pixels set.
You will get the pixels ID from the image itself.
Code: Select all
IQueryPrx service;
ParametersI param = new ParametersI();
param.map.put("id", omero.rtypes.rlong(pixelsID));
List files = service.findAllByQuery(
               "select ofile from OriginalFile as ofile left join " +
               "ofile.pixelsFileMaps as pfm left join pfm.child as " +
               "child where child.id = :id", param);

The call will return a collection of Original files.

Then you can read the data using the RawFileStore
Follow some pseudo-code

Code: Select all
int INC = 262144;
RawFileStorePrx store;
File f;// The file on client's machine
OriginalFile of; //object from the list returned in previous call.
stream = new FileOutputStream(f);
size = of.getSize().getValue();
try {
   for (offset = 0; (offset+INC) < size;) {
       stream.write(store.read(offset, INC)); //read the data
      offset += INC;
} finally {
stream.write(store.read(offset, (int) (size-offset)));

I will probably need to make the method available through one of the services, so it is easier to use.

User avatar
Team Member
Posts: 348
Joined: Thu May 21, 2009 6:38 pm
Location: dundee

Re: Archived original files

Postby johnjhufnagle » Mon Jun 28, 2010 5:30 pm

Thank you JMarie that worked nicely!
Posts: 34
Joined: Tue Dec 15, 2009 8:50 pm

Return to Developer Discussion

Who is online

Users browsing this forum: No registered users and 1 guest