Outputting files from a PostgreSQL database to the file system
Dear Sirs, Good day!
There was a problem with the output of files from the PostgreSQL database to the file system on the combat server. There is a code that runs locally on my computer on which MAMP is installed. The meaning of this code is to select data from the database and place the data in the file system directory, then send these files to a remote server (send with the php cURL library). On a combat server from another OS, these manipulations do not work, the code stops at selecting files from the database and placing them in the file system.
Local system OS: MacOS 10.14.1 MAMP version: 4.5 Web server: Apache / 2.2.34 (Unix) PHP version: 7.2.1
Operating system 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:
- Incorrectly sent the contents of the file - the file comes to the file system is broken, the file size is either zero or 1KB.
- The file name is transferred incompletely, on some character is cut. (PR: “prezentatsiya_1128329_435”, “prezentatsiya_1128329_Д). On the type of character - the number or letter does not depend. The name of the files comes from the database already translated into translit. (I made a translation from Russian literature into Latin using PHP, but this did not help, so we did transliteration into the database)
I assumed that there was some problem with the locale on Debian 9 and implemented 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 They work for the time of the terminal session, on the MacOS the OS language was English, for the time of the terminal session the language was switched to Russian, but when reconnecting to the server via the terminal, the locale settings were reset; The dpkg-reconfigure locales command did not affect the display of the command line interface. Changing the language on MacOS to Russian helped in displaying the Russian language in the terminal, but no more.
After applying these settings, the locale command shows the following results:
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= I assume that, after all, it’s a matter of locale settings, so I’m not attaching the working code, if necessary, I’ll add.
I was looking for information on setting up a locale on Debian took the instructions in this source, the Standard item , performed the following steps:
1. Редактировал файл /etc/default/locale, добавив строку LANG=ru_RU.UTF-8 2. Перезагружал сервер. 3. Не помогло 4. Смотрел файл /etc/locale.gen 5. После применения команды dpkg-reconfigure locales раскомментированы следующие строки "en_US.UTF-8 UTF-8", "ru_RU.UTF-8 UTF-8" 6. Не помогло Rules php.ini file - increased the size of sent files:
upload_max_filesize = 30M Sending files allowed, directive value:
file_uploads = On Post_max_size setting value:
post_max_size = 8M Tell me, what could be the cause of this problem? Where is the dog buried? There is not enough experience to independently determine in which direction to move to solve this problem.