I am trying to upload a file inside a repository on Alfresco.
I am using the Alfresco Mobile SDK for Android that is well documented and easy to use.
The problem is that I didn’t find how to create an object ContentFile from a file (the one that I want to upload), in order to use the method:
public Document createDocument(Folder folder, String nameFile,
Map<String,Serializable> properties, ContentFile contentFile)
(this method works great, I am able to create a file without content).
I am pretty sure it is not big deal but I am looking around and don’y manage to find what I need.
Thanks in advance for your help.
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);
You should use the
ContentFileImplclass: