I have a set of image imported from MSSQL in csv. The file size is 1gb. Datatype in MSSQL is image. When I want to import to Postgres, datatype in bytea, error occured.
ERROR: invalid byte sequence for encoding "UTF8": 0xff
CONTEXT: COPY photo, line 1
When I look into the csv file, the image file is in
0xFFD8FFE000104A46494600010101006000600000FFE1...
My questions:
- What datatype in PostgreSQL can be used to import this type of file?
- How to retrieve image from this type of file using Postgres and PHP?
Solution that I tried:
- I tried to copy just three lines and save to new csv file, import it into the photo table, and it succeed. Weird, why is it when I want to import whole csv table, error occurred.
- I have tried this https://stackoverflow.com/a/22211207/3602791 in my php using sample image and it was a success, but when I want to retrieve the three lines image that I imported, it failed saying that my image have an error.
http://pastebin.com/WrfjFqY6 This is a sample of line in the csv. 2 columns, id and photo.
Anyone know how to solve this? Thanks in advance.