Friday, June 14, 2019

Save binary files in MongoDB with Spring-Boot

Saving binary files in MongoDB is pretty simple with Spring-Boot. You simply need to put byte[] type in the CrudRepository entity:



public interface BinayFilesRepository extends MongoRepository<BinaryEntity, String> {

}

@Document(BinaryEntity = "binaries")
public class BinaryEntity {

    private String id;
    private byte[] data;

}

No comments:

Post a Comment