WCM API :Can't set File or Image for LibraryFileComponent or LibraryImageComponent

129 Views Asked by At

Today i try to create LibraryImageComponent or LibraryFileComponent on my wcm portal. Code as below :

workspace = createWorkspace();
DocumentLibrary documentLib = workspace.getDocumentLibrary(Config.LIBRARY_NAME);
    workspace.setCurrentDocumentLibrary(documentLib);
workspace.login();
try {
    LibraryFileComponent file = workspace.createFileComponent();
    file.setName("FileUploadDemo");
    File f = new File("C:/Users/huyenlt/Desktop/TinVeBIDV/TinVeBIDV/files/94747249_38ba_48fb_b150_7267fd7a1c9aCTR_KTA___GS_UBKT_2018.doc");
    file.setResource("helo",f);
    file.setFile("helo",f);
    workspace.save(file);
}
 catch (Exception e2) {
    // TODO Auto-generated catch block
    e2.printStackTrace();
}
}
0

There are 0 best solutions below