cancel
Showing results for 
Search instead for 
Did you mean: 

Uploading files greater than 4MB fails while using DotCMIS API

rita_aiyar
Champ in-the-making
Champ in-the-making
Hi,

I am using the DotCMIS APIs to upload a document (Ifolder.CreateDocument). When i upload documents whose size is less than 4 MB, it works perfectly but for files greater than 4 MB it fails. I checked the following discussion https://forums.alfresco.com/forum/developer-discussions/alfresco-api/cannot-upload-file-larger-4mb-u...

When i tried to look for the repository.properties file, i found two. One was under tomcat/webapps/alfresco/WEB-INF/classes/alfresco and the other under tomcat/webapps/alfresco/WEB-INF/classes/alfresco/enterprise. The repository.properties file under tomcat/webapps/alfresco/WEB-INF/classes/alfresco had the 3 properties
webscripts.tempDirectoryName=WebScripts
webscripts.memoryThreshold=4194304
webscripts.setMaxContentSize=4294967296

As mentioned in the forum, I gave full permission to the temp folder and also created the WebScripts folder under temp/Alfresco. This however did not solve my problem. I am getting the following error in the alfresco.log file.

00:45:14,785 ERROR [org.springframework.extensions.webscripts.AbstractRuntime] [http-bio-443-exec-9] Exception from executeScript - redirecting to status template error: 06300255 Wrapped Exception (with status template): 06302159 Failed to execute script 'classpath*:alfresco/templates/webscripts/org/alfresco/cmis/children.post.atom.js': com.ctc.wstx.exc.WstxIOException: Invalid chunk header
org.springframework.extensions.webscripts.WebScriptException: 06300255 Wrapped Exception (with status template): 06302159 Failed to execute script 'classpath*:alfresco/templates/webscripts/org/alfresco/cmis/children.post.atom.js': com.ctc.wstx.exc.WstxIOException: Invalid chunk header


Any help will be appreciated. Our work is getting stuck because of this.

Regards,
Rita
6 REPLIES 6

kaynezhang
World-Class Innovator
World-Class Innovator
I have tested it in my environment and uploaded a document more than 10m,it works fine.
Did you use any proxy servers(for example apache) in your alfresco environment?

Hi,

I have not used any proxy server in the alfresco environment.

Regards,
Rita

kaynezhang
World-Class Innovator
World-Class Innovator
Following is my test code in my environment  ,you can use it to test yours ,and if any error occurs ,please paste error log here

        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;
        }

When i use this code, the document gets created but the content is empty

protected void btnUpload_Click(object sender, EventArgs e)
        {
            ISession session = GetSession();
            IOperationContext oc = session.CreateOperationContext();
            //oc.IncludeAcls = true;
            IFolder root = session.GetRootFolder();
            // document name
            string fileName = upldAlfresco.FileName;
            // define dictionary
            IDictionary<string, object> properties = new Dictionary<string, object>();

            //properties.Add(PropertyIds.Name, fileName);
            properties.Add(PropertyIds.Name, "Test3.docx");
            properties.Add(PropertyIds.ObjectTypeId, "D:reflib:intel_rl_document");
            properties.Add("reflib:information_type", "testinfotype");
            properties.Add("reflib:content_type", "testcontenttype");
            properties.Add("reflib:additional_information", "testadditionalInfo");
            properties.Add("reflib:lifecycle_state", "Active");
            properties.Add("reflib:revision", "testrevision");

            string filePath = @"C:\Users\ritaaiya\Desktop\Test3.docx";

           
                FileStream fs = File.OpenRead(filePath);

                    byte[] bytes = new byte[fs.Length];
                    fs.Read(bytes, 0, Convert.ToInt32(fs.Length));
           

         
            ContentStream contentStream = new ContentStream
            {
                FileName = "Test3",
                MimeType = "application/msword",
                Length = fs.Length,
                Stream = fs   
            };

          
            try
            {
                ICmisObject rootFolder = session.GetObjectByPath("Repository/Reference Library/Test Rita/Inside Test Rita");

                IFolder iFolder = rootFolder as IFolder;

                IDocument doc = iFolder.CreateDocument(properties, contentStream, VersioningState.Major);

                fs.Close();

              
            }
            catch (Exception ex)
            {
                string test1 = ex.Message;
            }


        }

However when i use this code, the error is thrown:
protected void btnUploadLargeFile_Click(object sender, EventArgs e)
        {
            ISession session = GetSession();
            IOperationContext oc = session.CreateOperationContext();
            oc.IncludeAcls = true;
            IFolder root = session.GetRootFolder();
            // define dictionary
            IDictionary<string, object> properties = new Dictionary<string, object>();

            properties.Add(PropertyIds.Name, "23.docx");
            properties.Add(PropertyIds.ObjectTypeId, "D:reflib:intel_rl_document");
            properties.Add("reflib:information_type", "testinfotype");
            properties.Add("reflib:content_type", "testcontenttype");
            properties.Add("reflib:additional_information", "testadditionalInfo");
            properties.Add("reflib:lifecycle_state", "Active");
            properties.Add("reflib:revision", "testrevision");

            byte[] test = File.ReadAllBytes(@"C:\Users\ritaaiya\Desktop\23.docx");

            ContentStream contentStream = new ContentStream
            {
                FileName = "23.docx",
                MimeType = "application/msword",
                Length = test.LongLength,
                Stream = new MemoryStream(test)
            };

        
            try
            {
                ICmisObject rootFolder = session.GetObjectByPath("Repository/Reference Library/Test Rita/Inside Test Rita");

                IFolder iFolder = rootFolder as IFolder;

                iFolder.CreateDocument(properties, contentStream, null);

               

            }
            catch (Exception ex)
            {
                string test1 = ex.Message;
            }

        }


Any idea what i am doing wrong ?

asha_alex
Champ in-the-making
Champ in-the-making
Hi,
I am facing the same issue.I am using the exact same code given here and am able to upload small files.It looks like the issue is with the configuration rather than the code.These were the additional things configured in the web.config(.Net side).
1.) system.web tag
    httpRuntime maxRequestLength="2000000"  executionTimeout="84000" requestLengthDiskThreshold="80"


2.)system.webServer tag
        requestFiltering
        requestLimits maxAllowedContentLength="2147483648"
   
  3.)IIS->Request Filtering Settings->Max allowed content length to 2147483648


Please let me know if there is a configuration checklist I can verify against to get large files uploaded.
The error on the .Net side does not give out much about the actual error.I have attached it.

rjohnson
Star Contributor
Star Contributor
If you are accessing Alfresco via a web server check the limits on that, if via Tomcat, check the limits on that. Both methods have file size limits set independently of the Alfresco application