As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
private static void TestUploadDocument() { try { ISession session = GetSession(); IFolder folder1 = (IFolder)session.GetObjectByPath("/TESTFOLDER1"); Dictionary<string, object> properties = new Dictionary<string, object>(); properties[PropertyIds.ObjectTypeId]= "cmis:document"; properties[PropertyIds.Name] = "test20140730"; properties[PropertyIds.CreatedBy]= "admin"; VersioningState vs = VersioningState.Major; ContentStream contentStream = new ContentStream(); FileStream fs = new FileStream("D:\\test.pdf", FileMode.Open, FileAccess.Read); contentStream.Stream=fs; contentStream.FileName = "test upload"; contentStream.MimeType = "pdf"; Console.WriteLine(folder1.Name); folder1.CreateDocument(properties, contentStream, vs); fs.Close(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } private static ISession GetSession() { Dictionary<string, string> parameters = new Dictionary<string, string>(); parameters[DotCMIS.SessionParameter.BindingType] = BindingType.AtomPub; //parameters[DotCMIS.SessionParameter.AtomPubUrl] = "http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/atom"; //for 1.1 parameters[DotCMIS.SessionParameter.AtomPubUrl] = "http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.0/atom"; parameters[DotCMIS.SessionParameter.User] = "admin"; parameters[DotCMIS.SessionParameter.Password] = "admin"; SessionFactory factory = SessionFactory.NewInstance(); IList<IRepository> repos = factory.GetRepositories(parameters); ISession session = repos.ElementAt(0).CreateSession(); return session; }