Reputation: 179
I use a spring boot application with mongoDB as storage and want to store large image-files coded as base64 strings. As i know, mongoDB can only store files up to 16MB so i have to use gridfs. In multiple pages and tutorials they store files but i never found an example for storing objects with gridfs.
Basic example:
public class Student {
private String firstName;
private String lastName;
private String image;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image;
}
}
Do i have to store image-value seperately as an inputStream like mentioned here:
https://www.baeldung.com/spring-boot-mongodb-upload-file
Or are there other approaches?
Upvotes: 1
Views: 1554
Reputation: 524
you can store meta data with gridfs
OR
if you want to store complete object then follow below steps:
Upvotes: 2