title: Spring Content, convenient way to populate DB with images for test environment
body: <p>To store images I'm using Spring Content JPA strategy.
  My test profile has HSQLDB in-memory implementation.
  Is there a more convenient way to populate DB with images?
  For now, I have a solution to create a folder with images and then
  upload them manually on startup. As I understand, to get rid of the image folder I can upload them to SQLite and then fetch data from it, but maybe there is a better way?</p>
  <p><strong>CarrentalApplication</strong></p>
  <pre><code>@SpringBootApplication
  @EnableJpaRepositories
  @EnableJpaStores
  public class CarrentalApplication {
      private static final String IMAGE_FOLDER = &quot;classpath:static/img/test-cars/&quot;;
      private final Map&lt;Integer, String&gt; cars = new HashMap&lt;&gt;() {{
          put(100010, &quot;merc_benz&quot;);
          put(100011, &quot;volvo_s60&quot;);
          put(100012, &quot;suz_swift&quot;);
          put(100013, &quot;volks16v&quot;);
          put(100014, &quot;ford150&quot;);
          put(100015, &quot;lambo610&quot;);
          put(100016, &quot;bmvx5&quot;);
          put(100017, &quot;audis6&quot;);
      }};
  
      public static void main(String[] args) {
          SpringApplication.run(CarrentalApplication.class, args);
      }
  
      @Bean
      public CommandLineRunner uploadImages(CarService carService, CarRepository carRepository,
                                            CarImageStore imageStore) {
          return (args) -&gt; cars.forEach((carId, name) -&gt; {
              try {
                  Car car = carService.get(carId);
                  File file = ResourceUtils.getFile(IMAGE_FOLDER + name + &quot;.jpg&quot;);
                  FileInputStream input = new FileInputStream(file);
                  imageStore.setContent(car, input);
                  carRepository.save(car);
              } catch (Exception e) {
                  e.printStackTrace();
              }
          });
      }
  }
  </code></pre>
  <p><strong>CarImageStore</strong></p>
  <pre><code>@StoreRestResource(path = &quot;data&quot;)
  @Repository
  public interface CarImageStore extends ContentStore&lt;Car, String&gt; {
  }
  </code></pre>
  <p><strong>Car content fields:</strong></p>
  <pre><code>@ContentId
  private String contentId;
  
  @ContentLength
  private Long contentLength = 0L;
  
  @MimeType
  private String mimeType = &quot;text/plain&quot;;
  </code></pre>