Both bytea
and BLOB
are data types within the database for storing raw binary data. They aren't encodings, like base64 or the like, so there is no conversion to do per se.
However, in reality your application will handle this data in at least 5 forms:
- a PostgreSQL
bytea
column
- a variable in your server-side application (probably a string or byte-array)
- a stream of data in the API that links your server to your client (possibly encoded in some ASCII-safe form such as base64)
- a variable in your client-side mobile application
- an SQLite
BLOB
column
The data will flow through each of these forms in turn, so the conversions you need to worry about are not PostgreSQL to SQLite, but PostgreSQL to/from server-side language, server-side language to/from API encoding, and so on. You shouldn't need to make any changes to your mobile app if you change your server to use MySQL, or store the data in separate files, or find a way of creating it on the fly; the two ends of the process are completely separated.
This will be as much about using the right functions as explicitly understanding the encoding, just as storing the file to disk might involve the program environment manipulating the data, but you'd just write file.put(data)
or whatever.