Request for Assistance with Uploading and Linking Documents on Server

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sapyantuk
    Senior Member
    • Oct 2020
    • 265

    Request for Assistance with Uploading and Linking Documents on Server

    Is there a way to upload more than 500 documents, including their folder structure, to a server and create corresponding records in the document entity with the same folder structure?

    We have a requirement to upload a large number of documents, exceeding 500 in count. Manual uploading of each document is not a feasible task due to its complexity and time-consuming nature. Therefore, I am seeking an alternative approach. Is it possible to upload the entire folder containing the documents to the server, maintaining the folder structure, and automatically link and create records in the document section accordingly?
  • rabii
    Active Community Member
    • Jun 2016
    • 1250

    #2
    i thought the solution i have offered had solved your issue. for the last request you asked it is easy you just need to make a get request to all folder in the crm and loop through them to see if a folder in your directory exist then skip creating it. i will try to update the code for you and upload it.
    Rabii
    Web Dev

    Comment

    • sapyantuk
      Senior Member
      • Oct 2020
      • 265

      #3
      rabii I encountered an error that I'd like to discuss.

      The issue arises when we upload a document through the portal. Although records are being created, the problem lies in opening or downloading the file itself. It appears that the size of the file is consistently shown as 0 KB, indicating that there is no content within it.

      Upon conducting a thorough analysis of the issue, I discovered the root cause. The files are being scanned from the input path as expected, but the code seems to be searching for these files within the home directory where the application is hosted. This discrepancy in the search locations is likely the reason behind the empty files.

      Additionally, I wanted to bring to your attention another issue that I've come across. When we create or send files through the application, it seems that the files are not being posted in the same folder that already exists in Espo.

      To illustrate, let's say there is a folder in Espo called "Account." When I have some files on my local computer and attempt to upload them, the API creates a new folder named "Account" instead of posting the files in the existing directory in Espo.

      I was wondering if it would be possible to implement a check for the folder name. If the folder name already exists, we can then post the files in the existing directory in Espo. This would allow us to upload the documents in our desired structure by leveraging the same folder structure that exists in Espo.

      Combining the resolution of the file size issue and the implementation of the folder check feature would greatly improve the usability and organization of the application. I would appreciate your thoughts and guidance on how we can address these concerns.

      Thank you for your attention to these matters.

      Error

      Warning: mime_content_type(aarak traders OnlineCompanyRegistrationDetails-1.pdf): Failed to open stream: No such file or directory in C:\laragon\www\espofileapi\index.php on line 70

      Warning: filesize(): stat failed for aarak traders OnlineCompanyRegistrationDetails-1.pdf in C:\laragon\www\espofileapi\index.php on line 71

      Warning: file_get_contents(aarak traders OnlineCompanyRegistrationDetails-1.pdf): Failed to open stream: No such file or directory in C:\laragon\www\espofileapi\index.php on line 72
      ​​

      Comment

      • sapyantuk
        Senior Member
        • Oct 2020
        • 265

        #4
        rabii any update on this ?

        Comment

        • rabii
          Active Community Member
          • Jun 2016
          • 1250

          #5
          hey sapyantuk

          i have rewritten the code to cover the issue of the existing folder structure, however keep in mind that i assume that folder structure you have on your local pc is only a two dimension meaning (you have the main directory as the full path directory and subdirectories | without any nested subdirectories within each subdirectory) i hope this make sense, any the new version here will check existing folder structure in the CRM and will match files for existing folder, also one improvement is file checking meaning the system will not create a file twice, if a file already exist then the system will not process the post request for that specific file.

          I hope this solves your issue now, honestly this took me 3 hours to rewrite the whole code but i am hoping it will work for you.

          PS: API user should be able to read all DocumentFolder and all Attachment in the system.

          Cheers,
          Attached Files
          Rabii
          Web Dev

          Comment

          Working...