cancel
Showing results for 
Search instead for 
Did you mean: 

How to upload files in alfresco using Windows Forms ?

divyabharathipa
Champ in-the-making
Champ in-the-making
Hi Team,


How to upload documents in alfresco using Windows Forms ?

Please suggest me how to work with alfresco cmis in windows environment ?


Thanks,
Divya Palivela

5 REPLIES 5

hariprasad
Champ in-the-making
Champ in-the-making
———————————————————-
How to upload and download files to alfresco using Java Class,

I need a java class for the below items with different methods, could you please provide

1.   Upload File along with Meta Data
public void uploadFile( ) {

}

2.   Download File along with Meta Data
public void downloadFile( ) {

}

3.   Search File By Name
public void SearchFileByName( ) {

}

4.   Search File with Meta Data
public void SearchFileWithMetaData( ) {

}

5.   List GUIDs for Files matching the criteria
public void listOfGuids( ) {

}
6.   Search File by GUID

public void searchGuid( ) {

}
……………………………..
I have implemented in the below class for uploading to Alfresco,
i need similarly in different methods for the other items mentioned above,
could you please help on this,
………………………………..
public class AlfrescoUtil {

public static void main(String args[]) throws Exception {
String fileName = "upload.jpg";
WebServiceFactory.setEndpointAddress("http://localhost:8080/alfresco/soapapi");
AuthenticationUtils.startSession("admin", "admin");
ContentServiceSoapBindingStub contentService = WebServiceFactory.getContentService();
RepositoryServiceSoapBindingStub repositoryService =WebServiceFactory.getRepositoryService();

Store storeRef = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
String parentSpace = "/app:company_home/cm:ACH_Space";
ParentReference parentReference = new ParentReference (storeRef, null, parentSpace, Constants.ASSOC_CONTAINS, null);
parentReference.setChildName("cm:"+ fileName);

NamedValue[] contentProps = new NamedValue[3];
contentProps[0] = Utils.createNamedValue(Constants.PROP_TITLE,fileName);
contentProps[1] = Utils.createNamedValue(Constants.PROP_DESCRIPTION, fileName);
contentProps[2] = Utils.createNamedValue(Constants.PROP_NAME, fileName);

NamedValue[] aspectProps = new NamedValue[3];
aspectProps[0] = Utils.createNamedValue("{mandate}UMRN","18062014_01");
aspectProps[1] = Utils.createNamedValue("{mandate}IRN", "18062014_01");
aspectProps[2] = Utils.createNamedValue("{mandate}status", "TDS");

CMLAddAspect addAspect = new CMLAddAspect();
addAspect.setAspect("{mandate}mandateImage");
addAspect.setProperty(aspectProps);
addAspect.setWhere(new Predicate(new Reference[] { parentReference }, null, null));
addAspect.setWhere_id("1");

CMLCreate create = new CMLCreate("1", parentReference, parentReference.getUuid(), Constants.ASSOC_CONTAINS,null, Constants.PROP_CONTENT, contentProps);

CML cml = new CML();
cml.setCreate(new CMLCreate[] { create });
cml.setAddAspect(new CMLAddAspect[] { addAspect });
UpdateResult[] result1 = repositoryService.update(cml);
Reference content = result1[0].getDestination();
FileInputStream is = new FileInputStream("C:\\Users\\0021083\\Desktop\\PostGoLive4.jpg");

byte[] bytes = ContentUtils.convertToByteArray(is);

ContentFormat format = new ContentFormat("image/jpeg", "UTF-8");
contentService.write(content, Constants.PROP_CONTENT, bytes,format);
System.out.println("File Uploaded Successfully");
}

muralidharand
Star Contributor
Star Contributor
Hi Divya,
Please let me know, do you want use .net C# or VB.net windows forms?
In this case,you need use DOTCMIS.
Please refer the below links.
http://chemistry.apache.org/dotnet/dotcmis.html
http://chemistry.apache.org/dotnet/getting-started-with-dotcmis.html

Hi,
I know its pretty old thread.
But I am also facing the same issue as mentioned above.
My requirement is to develop a  website to perform upload,download using alfresco restful API in C#/VB without DOTCOMS.

Please suggest me how to work in this scenario.

Best Regards,
R.Dhamayandhi

nesralla
Champ in-the-making
Champ in-the-making
Hi,

did you find the answer for your issue !? i want to upload a file using .NET C# to alfresco upload api.
If you found can you help me send me a example ?

Thanks in advance
Igor

muralidharand
Star Contributor
Star Contributor
Hi,
Here is the sample C# which I have used to upload an image file .net to Alfresco Repo using CMIS.

IDictionary<string, object> DocumentProperties = new Dictionary<string, object>();DocumentProperties[PropertyIds.Name] = FileName;DocumentProperties[PropertyIds.ObjectTypeId] = "cmis:document";Stream temp = new MemoryStream(content);ContentStream contentStream = new ContentStream();contentStream.FileName = FileName;contentStream.MimeType = "image/jpeg";contentStream.Length = content.Length;contentStream.Stream = new MemoryStream(content);IDocument doc = documentTypeFolderRef.CreateDocument(DocumentProperties, contentStream, DotCMIS.Enums.VersioningState.Major);‍‍‍‍‍‍‍‍‍‍‍‍‍‍
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.

Welcome to the new Hyland Connect. Get started or submit feedback.