How Can I get a Java.io.File from a Content file?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2007 10:18 AM
How Can I get a Java.io.File from a Content file in Alfesco?
By Wes service?
Can you post an example code?
By Wes service?
Can you post an example code?
Labels:
- Labels:
-
Archive
4 REPLIES 4
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2007 01:58 PM
Hello,
You can get a ContentReader from the ContentService. This ContentReader is often (but not always) a FileContentReader which has a getFile method.
But you should * not * access repository files this way. Why not simply using InputStream and OutputStream provided by the ContentReader and ContentWriter ?
You can get a ContentReader from the ContentService. This ContentReader is often (but not always) a FileContentReader which has a getFile method.
But you should * not * access repository files this way. Why not simply using InputStream and OutputStream provided by the ContentReader and ContentWriter ?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2009 07:55 AM
Hi Rivarola and Roberto
I am trying to do the same, get a content node from Alfresto and transform it in a java.io.file as then I will need to assign it to a java.awt.Image.
I am trying to access the content and assign it to the java.io.File vable, but I get error messages that means the way I do it is wrong. I am using the ContentReader as you suggest in the post, however I dont find the getFile() method you say:
Any ideas of what I am duing wrong to use ContentReader to get the file from Alfresco?
Thanks a lot in advance guys
I am trying to do the same, get a content node from Alfresto and transform it in a java.io.file as then I will need to assign it to a java.awt.Image.
I am trying to access the content and assign it to the java.io.File vable, but I get error messages that means the way I do it is wrong. I am using the ContentReader as you suggest in the post, however I dont find the getFile() method you say:
Node Documento_Aux = this.browseBean.getDocument(); File imagen_Original ; ContentReader lectura = this.getFileFolderService().getReader(Documento_Aux.getNodeRef()); lectura.getContent(imagen_Original); //Here it fails saying that the file is incorrect or null BufferedImage orignalBF = ImageIO.read(imagen_Original); Image original_Img = toImage(orignalBF);
Any ideas of what I am duing wrong to use ContentReader to get the file from Alfresco?
Thanks a lot in advance guys
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2009 01:44 AM
I think this should workd:
Ask your reader for the stream, and have the image read that.
BufferedImage image = ImageIO.read(reader.getContentInputStream());
Ask your reader for the stream, and have the image read that.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2009 05:57 AM
Thanks a lot worked fine now!!