简体   繁体   中英

PostgreSQL 9.x - pg_read_binary_file & inserting files into bytea

I have been looking everywhere (google, stackoverflow, etc.) for some documentation on how to use the PostgreSQL pg_read_binary_file() function.

The only meaningful thing I can find is this page in the official documentation.

Every time I try to use this function I get an error.

For example:

    SELECT pg_read_binary_file('/some/path/and/file.gif');
    ERROR:  absolute path not allowed

or

    SELECT pg_read_binary_file('file.gif');
    ERROR:  could not stat file "file.gif": No such file or directory

Do I need to have my file in a specific directory for Postgres to have access to it? If so what directory?


If it matters, the reason I am looking at this function is because I am trying to insert a file into the database without doing crazy things .

As stated by @a_horse_with_no_name and @guedes the solution is to ensure that the file being uploaded is on the server in the PGDATA directory.

The postgres documentation does state the file location as a requirement.

Additionally, I made a symlink from another directory to the PGDATA directory so that I would not disturb any of the postgres data structure. This seems to be working well and I don't have to do any of the above crazy things .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM