Not getting uploaded file id immediately

Hello, I’m using mayan as our document manager. We created a wrapper rest api service which actually communicate with mayan through its rest api, now we are only using 2 apis of mayan: 1. upload 2. download. now the download api is quick and ok. But while uploading an file, I got the document id immediately from the upload response. But I need the fileId immediately too, because later on while downloading the file I need to save that file id in my own db. But unfortunately mayan is unable to do so. I mean right after uploading a file, then getting the file latest with that document id dont give the file information (e.g. fileId) immediately, rather If I do some delay and then try to get the file information under that uploaded document then I got the response. But its uncertain that after how much iteration I could get this. So if I want to jus get the file information (e.g. fileId) right after uploading any document, what to do?
Thanks in advance

Please use the search feature to find previous discussions about this topic. If you are developing external applications using Mayan, consider supporting the project with a support subscription Mayan EDMS or with via the new, low cost Knowledge base subscription Mayan EDMS community forum

In order to support scaling to millions of documents, almost everything in Mayan is an asynchronous operation, as such they happen at an undetermined time in the future. Attempting to acquire ID of new objects with long processing times is a paradigm of document management systems only meant for personal use and not suitable for large scale deployments. The document ID should be obtained in other ways depending on your workflow.

However, to fulfill this frequent request, we added a feature we call “immediate mode” to the sources system. Enabling this mode will provide a new document ID but will use an alternate code path that will disable performance and scaling features of Mayan and it is not suitable for mass uploads. Information about “immediate mode” is available in the release notes:

https://docs.mayan-edms.com/releases/4.5.html#sources

Support was added for single or multiple document API uploads. This feature is called immediate mode and allow receiving a document ID immediately after a file is submitted to a source via the API. This document ID allows working with the document while it is being processed. Since only one document ID can be returned per upload, using immediate mode will disable processing compressed files.

As well as a detailed Knowledge base article:

Sources API “Immediate Mode”

Other articles or discussions about or related to this topic:

Watch Folder/IMAP Source Processing

Background tasks

The event system

Document processing process

Thanks for your quick reply. Here is my workflow:

  1. Client uploads a file using the wrapper service api
  2. That wrapper service then calls the upload api of Mayan and upload the file, then immediately get the doc I’d in the response from Mayan .
  3. Then the wrapper service calls the get document api to get the latest file information to get the uploaded file id.
  4. Now in this stage Mayan don’t give the file latest information in the first time, then the wrapper service have a very hackish logic to retry for multiple times to get the latest file id.
  5. After getting the file id, wrapper service return docid and fileid in the response to the client browser
  6. Then when client try the save operation like he is actually filling up some form with some document, then that docid and fileid being saved with that form submit, so that, once the client get back to the saved form, he could see a link to download the uploaded files.
    So basically for client we are using Mayan as simple file storage, but we are using Mayan as document manager for admin users who actually get the Mayan ui interface and take the advantages of Mayan like ocr etc through Mayan.
    Now as I said for external client it’s just a file storage, so I need that latest file id of the uploaded document
    You have proposed for immediate mode, and you mentioned that it will return the doc Id immediately, but doc id is returned immediately, but I need the latest file id.
    I’ll explore your packages for subscription for support.
    Waiting for your reply.