cancel
Showing results for 
Search instead for 
Did you mean: 

How to upload new version of document in alfresco using DotCMIS and How to Show Version History Update..

shivtechno
Champ in-the-making
Champ in-the-making

Hi

i am trying to dot this asked question by using below code .

                #region --Authendication Masters..

                Dictionary<string, string> parameters = new Dictionary<string, string>();

                parameters[DotCMIS.SessionParameter.BindingType] = BindingType.AtomPub;

                parameters[DotCMIS.SessionParameter.AtomPubUrl] = "http://127.0.0.1:8080/alfresco/api/-default-/public/cmis/versions/1.0/atom";

                parameters[DotCMIS.SessionParameter.User] = UserName;

                parameters[DotCMIS.SessionParameter.Password] = Password;

               

                SessionFactory factory = SessionFactory.NewInstance();

                ISession session = factory.GetRepositories(parameters)[0].CreateSession();

                #endregion

              

                if (file == null)

                {

                    ViewBag.Message = "Please upload document.";

                }

                else if (file.ContentLength > 20728650)

                {

                    ViewBag.Message = "File size exceeds maximum limit 20 MB.";

                }

                else

                {

                    Document doc = ((Document)session.GetObject("workspace://SpacesStore/" + objectId));

                    // define dictionary for document

                    IDictionary<string, object> properties = new Dictionary<string, object>();

                    properties.Add(PropertyIds.Name, file.FileName);

                    properties.Add(PropertyIds.ObjectTypeId, "cmis:document");

                    //properties.Add(PropertyIds.ObjectId, objectId);

                    properties.Add(PropertyIds.CheckinComment, CheckInComment);

                    //folder Path storing Version Document..

                    IFolder folder = (IFolder)session.GetObjectByPath("/VersionControlDir");

                    byte[] data = new byte[file.ContentLength];

                    file.InputStream.Read(data, 0, data.Length);

                    ContentStream contentStream = new ContentStream

                    {

                        FileName = file.FileName,

                        MimeType = file.ContentType,

                        Length = file.ContentLength,

                        Stream = new MemoryStream(data)

                    };

                  

                    folder.CreateDocument(properties, contentStream, DotCMIS.Enums.VersioningState.CheckedOut);

                    IObjectId ob = doc.CheckIn(true, properties, null, CheckInComment);

                }

            }

1 ACCEPTED ANSWER

kaynezhang
World-Class Innovator
World-Class Innovator

You can use   GetAllVersions(IOperationContext context); mehtod of IDocument class to get a list of all versions .

Use VersioningState.Major/minor parameter of IFolder.CreateDocument/ISession.CreateDocument to controll major/minor version creation

View answer in original post

1 REPLY 1

kaynezhang
World-Class Innovator
World-Class Innovator

You can use   GetAllVersions(IOperationContext context); mehtod of IDocument class to get a list of all versions .

Use VersioningState.Major/minor parameter of IFolder.CreateDocument/ISession.CreateDocument to controll major/minor version creation

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.