Reputation: 175
I am new to PLPGSQL.
I am developing an application where the user will select an image and on submit plpgsql procedure will be called which will save the image on server.
Is there any way to convert BLOB data to image in plpgsql as the image is coming in BLOB format?
Upvotes: 2
Views: 396
Reputation: 658907
You can use server-side function for large objects. There are code examples in the manual:
SELECT lo_export(image.raster, '/tmp/motd') FROM image
WHERE name = 'beautiful image';
This writes a file to the file system on the server.
To call this from a PL/pgSQL function, you would replace SELECT
with PERFORM
.
Often it is more efficient to store images in the file system to begin with. Consider this related answer:
Storing long binary (raw data) strings
Upvotes: 1