I'm working with Liquibase for the db population. Have one entity definition file with the field:
<column name="image" type="longblob"></column>
And load-data configuration:
<loadData encoding="UTF-8" file="images.csv"
separator=";" tableName="images">
</loadData>
In the input csv file I have 3 columns: 1) name 2) type 3) image
So my question is: is it possible to have in the input file field "image" filled with PATH to the image ("/test.png"), and in the db populate it as a BLOB uploading the image from provided in the *.cvs path?
Yes, it is possible.
Simply use the path to the image file in CSV file in place where you have column for image data.
Like in this CSV file:
id,description,image
1,'just my image',/path/to/the/image
2,'nice image',/path/to/another/image
And you can define your liquibase changelog file like this:
<databaseChangeLog
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
<changeSet id="1" author="Johny.Walker">
<loadData tableName="Image"
file="image_test_data.csv"
separator=","
quotchar="'"/>
</changeSet>
</databaseChangeLog>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With