将createDocument(...)与Android的Alfresco Mobile SDK一起使用,如何从文件中获取ContentFile?

时间:2013-01-25 10:59:45

标签: android upload alfresco

我正在 Alfresco 上的存储库中上传文件。

我正在使用Alfresco Mobile SDK用于 Android ,该SDK已有详细记录且易于使用。

问题是我没有找到如何从文件(我要上传的文件)创建对象ContentFile,以便使用该方法:

public Document createDocument(Folder folder, String nameFile,
Map<String,Serializable> properties, ContentFile contentFile)

(这种方法效果很好,我可以创建一个没有内容的文件)。

我很确定这不是什么大问题,但我环顾四周,并没有找到我需要的东西。 在此先感谢您的帮助。

ServiceRegistry serviceRegistry = Login.session.getServiceRegistry();
DocumentFolderService documentFolderService = 
    serviceRegistry.getDocumentFolderService();
Folder folder = (Folder) 
    documentFolderService.getNodeByIdentifier(repository.getIdentifier());

Map<String,Serializable> properties = new HashMap<String,Serializable>();

// here I would like to take the content from the fileFrom:
ContentFile contentFile = null; 

// fileFrom is a File object:
String nameFile = fileFrom.getName(); 

documentFolderService.createDocument(folder, nameFile, properties, contentFile);

1 个答案:

答案 0 :(得分:5)

您应该使用ContentFileImpl类:

//...
String location = "..."; // wherever you have to point to
ContentFile contentFile = new ContentFileImpl(new File(location));
//...