• How to just download a document from the OKM Repo

  • Do you want to create a native client or integrate with third party applications: webservices are the solution.
Do you want to create a native client or integrate with third party applications: webservices are the solution.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #8662  by rocabu
 
Hi people, I have a question to make.

I am trying to complete the whole process for documents on the OKM Repository (create, check-out and check-in) from another application I have running on a server (Microsoft CRM)

I have completed the creation process, and thought I finished the checkout + document update + checkin cycle back again on the okm repository. But when I published the code on the server I realized that the download process was not going to work because obviously the server is unable to create content on the client side.

Honestly I have no idea about how to download content directly from the OKM and into the client, is there any example that might help? Here is the code I have for the checkout-checkin process. I know the checkin process will work when solving this issue, but in the meantime I am hands-tied. I know I have to use some other actions like documentService.setContent and documentService.checkin
Code: Select all
        private void checkoutDocumentFromOpenKm(String username, String password)
        {
            try
            {
                // OpenKM authentication
                token = authService.login(username, password);

                //Gets the content from the file and builds a new one locally, then does the checkout so nobody can edit it.
                //documentService.cancelCheckout(token, "/okm:root/Proposals System/Base Components/test.txt");
                byte[] localFile = documentService.getContent(token, okmPath, false);
                writeByteArrayToFile(localFile, Constants.LOCAL_FILE_LOCALIZATION + okmFileName + okmFileExtension);
                documentService.checkout(token, okmPath);

                // Logout OpenKM
                logOutOpenKm(token);
                lblUploadStatus.Text = Constants.SUCCESS_MESSAGE_DOWNLOAD + okmFileName + okmFileExtension;
            }
            catch (Exception ex)
            {
                logOutOpenKm(token);
                lblUploadStatus.Text = Constants.ERROR_MESSAGE_DOWNLOAD + ex.ToString();
            }

        }

//Checkin

        private void checkinDocumentToOpenKm(String username, String password)
        {
            try
            {
                //string localFilePath = Server.MapPath(Constants.LOCAL_TEMPORAL_FOLDER) + FileUpload.FileName;
                //string localFilePath = FileUpload1.Attributes["Value"];
                FileUpload1.PostedFile.SaveAs(Constants.LOCAL_TEMPORAL_FOLDER);

                // OpenKM authentication
                token = authService.login(username, password);

                // Upload a document to OKM
                byte[] localFile = readFile(Constants.LOCAL_TEMPORAL_FOLDER);
                documentService.setContent(token, okmPath, localFile);
                documentService.checkin(token, okmPath, "");

                // Logout OpenKM
                logOutOpenKm(token);
                lblUploadStatus.Text = Constants.SUCCESS_MESSAGE_UPLOAD;

                // Deleting the temp file
                //File.Delete(Constants.LOCAL_TEMPORAL_FOLDER);
            }
            catch (Exception ex)
            {
                logOutOpenKm(token);
                lblUploadStatus.Text = Constants.ERROR_MESSAGE_UPLOAD + ex.ToString();
            }
        }
Thanks a lot for your help.
 #8663  by rocabu
 
Oh! Yes, I forgot to say that I already checked on the OpenWordAddIn code but could'nt find anything useful (at least something I recognize I can use). I am not an expert with this... as you can see.....

Thanks!

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.