Commit 605dc3c8 by Bogdan Andjelkovic

update back - finished

parent 7eff757e
...@@ -75,8 +75,13 @@ public class AppController ...@@ -75,8 +75,13 @@ public class AppController
return "redirect:/profile"; return "redirect:/profile";
} }
@PostMapping("/picture-update") @PostMapping("/picture-update")
public String izmeniSliku(@AuthenticationPrincipal KorisnikDetails korisnik,@RequestParam("image") MultipartFile file) throws IOException { public String izmeniSliku(@AuthenticationPrincipal KorisnikDetails loggedUser,@RequestParam("image") MultipartFile file) {
kRepo.updateSlika(korisnik.getKorisnik(),file); kRepo.updateSlika(loggedUser.getKorisnik(),file);
try {
loggedUser.setKorisnikSlika( Base64.getEncoder().encodeToString(file.getBytes()));
} catch (IOException e) {
throw new RuntimeException(e);
}
return "redirect:/profile"; return "redirect:/profile";
} }
} }
...@@ -64,7 +64,6 @@ public class KorisnikRepository ...@@ -64,7 +64,6 @@ public class KorisnikRepository
slika = Base64.getEncoder().encodeToString(file.getBytes()); slika = Base64.getEncoder().encodeToString(file.getBytes());
sql = " update korisnik " + sql = " update korisnik " +
" set slika = '" + slika + "' where korisnikid = " + korisnik.getKorisnikId(); " set slika = '" + slika + "' where korisnikid = " + korisnik.getKorisnikId();
System.out.println( sql);
statement.executeUpdate( sql); statement.executeUpdate( sql);
} catch (SQLException e) { } catch (SQLException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment