Hello everyone,
I want to know that how and where attachments are stored in openmrs.
Is the whole attachment stored in the database or only attachment’s path is stored in the database ?
So in short i want to know that is attachment stored in database or in openmrs-core directory ?
1 Like
herbert24
(Herbert Yiga)
March 17, 2021, 1:02pm
2
the image name is stored to the database and the image to the server,checkout
conceptComplex = context.getConceptComplex(ContentFamily.IMAGE);
prepareComplexObs(visit, person, encounter, fileCaption);
Object image = multipartFile.getInputStream();
double compressionRatio = getCompressionRatio(multipartFile.getSize(), 1000000 * context.getMaxStorageFileSize());
if (compressionRatio < 1) {
image = Thumbnails.of(ImageIO.read(multipartFile.getInputStream())).scale(compressionRatio).asBufferedImage();
}
obs.setComplexData(
complexDataHelper.build(instructions, multipartFile.getOriginalFilename(), image, multipartFile.getContentType())
.asComplexData());
obs = context.getObsService().saveObs(obs, getClass().toString());
return obs;
}
public Obs saveOtherAttachment(Visit visit, Person person, Encounter encounter, String fileCaption,
MultipartFile multipartFile, String instructions) throws IOException {
conceptComplex = context.getConceptComplex(ContentFamily.OTHER);
prepareComplexObs(visit, person, encounter, fileCaption);
what is stored in the database ? Image name or Image path.
1 Like
ok so on which basis it fetches image from the server.
On the basis of Image name ?
1 Like
mksd
(Dimitri R)
March 17, 2021, 1:20pm
6
@pratikbiz24 the first things to know is that an attachment is just some kind of wrapper for a complex obs . Complex obs are saved by default in the OpenMRS app data dir inside the /complex_obs
subfolder.
It is the value_complex
field of the complex obs that holds parseable string data to its location.
There is no general rule as to what’s stored in the database within the obs’ value_complex
(image name vs image path vs whatever other locator info), that depends on the complex obs handler defined for a given complex obs.
2 Likes
Thanks @mksd , Now i understood how it’s working .
2 Likes