Answer the question
In order to leave comments, you need to log in
How to correctly transfer files from the database to the file system?
Outputting files from the database to the file system
Dear sirs, good afternoon!
There was a problem with the output of files from the PostgreSQL database to the file system on the production server. There is a code that works locally on my computer, on which MAMP is installed. The meaning of this code is to select data from the database, place the data in the file system directory, then send these files to a remote server (send using the php cURL library). On a combat server with a different OS, these manipulations do not work, the code stops at fetching files from the database and placing them in the file system.
Local OS: MacOS 10.14.1 MAMP Version: 4.5 Web Server: Apache/2.2.34 (Unix) PHP Version: 7.2.1
Combat OS: Debian GNU/Linux 9.4 (stretch) Web Server: Apache/2.4. 25 (Debian) PHP version: 7.0.30-0+deb9u1
When outputting files on the combat server from the database, the following errors occur:
The contents of the file are sent incorrectly - the file arrives in the file system broken, the file size is either zero or 1KB.
The file name is transmitted incompletely, on some character it is cut. (PR: “prezentatsiya_1128329_435”, “prezentatsiya_1128329_Д). The character type does not depend on a number or a letter. The name of the files comes from the database already translated into transliteration. (I did a translation from Russian to Latin using PHP, but this did not help, so we did the transliteration in the database)
I assumed that there was some problem with the locale on Debian 9 and took the following steps:
1. export LANGUAGE=ru_RU.UTF-8
2. export LANG=ru_RU.UTF-8
3. export LC_ALL=ru_RU.UTF-8
4. locale-gen ru_RU.UTF-8
5. apt-get install --reinstall locales
6. dpkg-reconfigure locales
LANG=ru_RU.UTF-8
LANGUAGE=
LC_CTYPE="ru_RU.UTF-8"
LC_NUMERIC="ru_RU.UTF-8"
LC_TIME="ru_RU.UTF-8"
LC_COLLATE="ru_RU.UTF-8"
LC_MONETARY="ru_RU.UTF-8"
LC_MESSAGES="ru_RU.UTF-8"
LC_PAPER="ru_RU.UTF-8"
LC_NAME="ru_RU.UTF-8"
LC_ADDRESS="ru_RU.UTF-8"
LC_TELEPHONE="ru_RU.UTF-8"
LC_MEASUREMENT="ru_RU.UTF-8"
LC_IDENTIFICATION="ru_RU.UTF-8"
LC_ALL=
upload_max_filesize = 30M
file_uploads = On
post_max_size = 8M
Answer the question
In order to leave comments, you need to log in
The contents of the file are sent incorrectly - the file comes to the file system broken, the file size is either zero or 1KB.It is worth checking that the files are indeed stored intact in the DBMS by checking their size through the PostgreSQL client.
The file name is incompleteThen make sure the PHP program uses a variable of the appropriate size to store the filename.
Now I hang try / catch on all parts of the code. Perhaps this will somehow help in detecting errors.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question