Accessing files from the dolibarr database
Hello everyone,
I am a new developer. I am doing an internship and I am building a management application for a small complementary cabinet using Dolibarr. It's the software used by the cabinet for tracking and archiving legal files.
I have encountered a problem. I need to display the decisions for completed legal cases (for which a decision has been made).
- First problem: the decisions are not entered into the database or even summarized. However, the decisions are rendered in physical form, then scanned and uploaded to Dolibarr for the relevant case.
- First solution: using an OCR to scan the files uploaded in PDF format, extract the text, and display it on demand.
- Second problem: access to the files. I cannot access the files because I am unable to reconstruct the access path to reach them. Not the path through which Dolibarr (the application) accesses, but according to my research, the root path.
Could someone guide me on the composition of this root path or suggest another solution?
1 answer
Hello,
I know Dolibarr by name but I've never used it, so my advice will probably be a bit vague, but I hope it will help you. Also try to create a discussion thread for each problem.
Regarding your first problem: if I understand correctly, you are performing OCR on every upload, which allows you to store a text version in the database and search at will. In fact, in the design of your application, OCR should only be done once at most, as it is a time and energy-consuming operation. Personally, I would do it whenever a PDF is uploaded.
Regarding your second problem:
Preliminaries
To help you better understand your problem, I think it's useful to recall how a web server works.
A web server is an application that runs in the background and waits for clients (web) to connect to it to serve their requests. Two classic examples of web servers are apache2 or nginx. When you have a related request, it is useful to specify what you are using because their configuration files are organized differently.
dolibarr is a web application and can therefore only operate through a web server. In practice, dolibarr likely corresponds to a virtual host from the web server's perspective. A vhost is a convenient way to host multiple web applications on the same web server (one vhost per application). It is called a virtual host because everything happens "as if" multiple sites (hosts) were hosted on the same machine.
Now let’s move on to the concept of virtual host. Depending on the address with which the client (the browser) reaches the web server, a vhost knows whether it is involved or not. Obviously, you'd need to see how the server is configured in your case to say more, but intuitively, we can imagine that the dolibarr vhost is configured to recognize that https://mon-site.fr/dolibarr concerns it.
More specifically, the web server configuration includes the definition of 0 or more vhosts.
- Example: In Linux Debian and distributions, a vhost is defined in apache2 with a dedicated file stored in /etc/apache2/sites-available. A vhost is activated or not based on vhosts referenced in /etc/apache2/sites-enabled. This referencing is corrected with the commands a2ensite and a2dissite.
Each vhost configuration file specifies:
- when it is relevant (address and port used by the client),
- its root directory (called DocumentRoot in apache2) corresponding to a particular folder on the file system.
- For example, if your web server is running on Linux, dolibarr’s DocumentRoot will likely be something like /var/lib/dolibarr. This means that when you refer to https://mon-site.fr/dolibarr/toto, you are trying to access /var/lib/dolibarr/toto.
The DocumentRoot is critical because a URL cannot go "higher" than the DocumentRoot folder. In my example:
- https://mon-site.fr/dolibarr/toto corresponds to /var/lib/dolibarr/toto
- https://mon-site.fr/dolibarr/ corresponds to /var/lib/dolibarr/ and since it is the DocumentRoot, you cannot go higher.
Back to your problem
You need to clarify your problem:
- what web server are you using? what operating system?
- what is the target file?
- what is the DocumentRoot of dolibarr?
- how are you trying to access this file? Is it the client, through a URL? Is it a piece of code in PHP (thus server-side)?
If you are trying to construct a URL, you should check:
- what is the path of the file you are attempting to access
- ensure that this path is within the folder or a subfolder of the dolibarr vhost root
Good luck