AnsweredAssumed Answered

Send image file to alfresco server with Webservices

Question asked by anurak on Jan 31, 2006
Latest reply on Feb 2, 2006 by anurak
I have a problem when created a new content(image) to alfresco server with webservices. The content showed in alfresco but when clicked on an image it did not show correctly. I try to check from the forums but can not found any information. Can i send any image to alfresco server with webservices or not? Below is my code, everything fine when i run.

======== CODE ==========
        ContentFormat contentFormat = new ContentFormat("image/jpeg", null);

        NamedValue[] properties = new NamedValue[]{new NamedValue(ContentModel.PROP_NAME.toString(), name)};
        CMLCreate create = new CMLCreate("1", parentReference, ContentModel.TYPE_CONTENT.toString(), properties);
        CML cml = new CML();
        cml.setCreate(new CMLCreate[]{create});
        UpdateResult[] result = getRepositoryWebService().update(cml);    
        Reference newContentNode = result[0].getDestination();
        File file = new File("C:\\Documents and Settings\\admin\\My Documents\\DSC01989.JPG");
        FileInputStream in  = new FileInputStream(file);
        int size=(int)file.length();
        byte[] bytes=new byte[size];;
        Content content = contentService.write(newContentNode, ContentModel.PROP_CONTENT.toString(), bytes, contentFormat);