2017-08-02 7 views
0

私はCMISを学習しており、CMISを使用して文書を作成する次のようなコードを発見しました。 CMISのcreateDocumentメソッドを使用して、ローカルマシンのフォルダに保存されているファイルをアップロードします。それをどうすれば実現できますか?CMISを使用してドキュメントをアップロードするには?

+0

'FileInputStream'の何が問題なのですか? – Gagravarr

答えて

0

私はあなたがまたHow to get connected with Alfresco repository(simplly GETセッションで多くを読むことができ、この方法をテストしてみたし、それが私

public static void upload(String serverUrl, String username, String password, String cheminFichierSource, String nomDestination, String cheminFichierDestination, String extentionFichier) { 
try {  
    Session session = getSession(serverUrl, username, password); 
    Folder root = getFolderByPath(serverUrl, username, password, cheminFichierDestination); 

    Map<String, Object> properties = new HashMap<String, Object>(); 
    properties.put(PropertyIds.OBJECT_TYPE_ID, BaseTypeId.CMIS_DOCUMENT.value()); 
    String name = nomDestination + "." + extentionFichier; 

    System.out.println("name:" + name); 
    properties.put(PropertyIds.NAME, name); 
    List<Ace> addAces = new LinkedList<Ace>(); 
    List<Ace> removeAces = new LinkedList<Ace>(); 
    List<Policy> policies = new LinkedList<Policy>(); 
    File file = new File(cheminFichierSource); 
    ContentStream contentStream = new ContentStreamImpl("content." + extentionFichier, BigInteger.valueOf(file.length()), 
new MimetypesFileTypeMap().getContentType(file), new FileInputStream(file)); 
    Document dc = root.createDocument(properties, contentStream, VersioningState.MAJOR, policies, addAces, removeAces, session.getDefaultContext()); 
//idnewdoc=dc.getId(); 

    } catch (FileNotFoundException e) { 
    JOptionPane.showMessageDialog(null, e.getMessage(), "ERREUR Consultation! ", JOptionPane.ERROR_MESSAGE); 
    } 
    } 

のために働いています方法)。

また、このメソッドではすべてのものが静的(ファイル名のパス...)であることを忘れないでください。

あなたを助けた希望。

関連する問題