Link

Retrieving a FileDocument from a filepath

Ariel Cohen - on 2/22/06 at 6:58 PM

I'm trying to retrieve a FileDocument but I only have it's filepath. Do I have to iterate over each FD to find it ?

Re: Retriving a FileDocument from a filepath

Olivier Dedieu - on 2/22/06 at 8:08 PM

You can use channel.getFileIndexedDataSet(). This method returns the set of publication bound to the given path. This set can contains FileDocument but also other publications types which reference the file (e.g. through an "image" field).

Example :

// Get the publication set bound to "picture.jpg"
TreeSet set = channel.getFileIndexedDataSet("upload/image/jpg/picture.jpg");

// Retain only the FileDocuments
set = (TreeSet)Util.interSet(set, channel.getDataSet(FileDocument.class));

if (Util.notEmpty(set)) {

  FileDocument fileDoc = (FileDocument)(set.iterator().next());
  ...
}
Login   Home   fr en
JALIOS SA - SIREN 440 126 035