I have file.zip
in DB like BLOB
. I want create method in Spring controller for download this file on client side.
@RequestMapping(value = "/downloadResolution/{resolutionId}", method = RequestMethod.GET)
public void downloadResolution(@PathVariable("resolutionId") Long resolutionId, HttpServletResponse response) {
Resolution resolution = resolutionService.findOne(resolutionId);
ResolutionArchive resolutionArchive = resolution.getResolutionArchive();
if (resolutionArchive == null) return;
byte[] archive = resolutionArchive.getArchive();
//this byte[] archive - my zip file from db
}
How can I change this methot In order to download this on client side?
User press download button. Methos get data from DB in byte[] and user can download it.
EDIT
I tried solution of @pleft and it work. and I knew - I use ajax for call method
function downloadResolution(resulutionId) {
$.ajax({
type: 'GET',
dataType: "json",
url: '/downloadResolution/' + resulutionId,
success: function (data) {
},
error: function (xhr, str) {
}
});
}
How realize this if I use ajax?