0
我的java支持的webscript將存儲庫中的文件複製到臨時文件夾並根據我的需要進行編輯。在工作過程中,會生成一個新內容並將其寫入創建的臨時文件。如何更新Alfresco中的文件內容?
但存在一個問題:下面的第一個或第二個代碼不會更新文件的內容。
ContentWriter contentWriter = this.contentService.getWriter(tempFile,
ContentModel.PROP_CONTENT, true);
contentWriter.putContent(content);
而第二個:
`
WritableByteChannel byteChannel = contentWriter.getWritableChannel();
ByteBuffer buffer = ByteBuffer.wrap(content.getBytes());
byteChannel.write(buffer);
byteChannel.close();
`
如何更新文件的內容?
我想替換臨時文件上的全部內容。你的代碼不適用於它。 – Alexey
嗨如果你想取代所有的東西,只是不要使用該行:fileChannel.position(contentWriter.getSize()); 然後默認使用0作爲起始位置。 –
它不起作用。我試圖評論該行並設置爲零:fileChannel.position(0)。 Alfresco Web客戶端(/ alfresco)顯示該文件已被修改(日期更改),但其內容不是。 – Alexey