Hi, can someone give me alternatives to upload files. I use just the following piece of code:
// Open the file and convert to byte array
InputStream viewStream = newContentNode.getClass().getClassLoader().getResourceAsStream("test.jpg");
byte[] bytes = null;
try
{
bytes = ContentUtils.convertToByteArray(viewStream);
}
catch (Exception e)
{
…
}
// Write the content
ContentServiceSoapBindingStub contentService = WebServiceFactory.getContentService();
Content contentRef = null;
try
{
contentRef = contentService.write(newContentNode, Constants.PROP_CONTENT, bytes, format);
}
catch (ContentFault e)
{
…
}
catch (RemoteException e)
{
…
}
My problem is that the file test.jpg is in the same folder as the class. But I want to upload files from another folder.Here is test.jpg : ProjectFolder/WEB-INF/classes/package1/package2/But I want from that folder. : ProjectFolder/TempFolder/This code does not work.
InputStream viewStream = newContentNode.getClass().getClassLoader().getResourceAsStream("../../../../../TempFolder/test.jpg");
Has anyone a solution for this problem or an idea?