Advertisement
Guest User

Untitled

a guest
Dec 11th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. public class Image implements Serializable {
  2.  
  3. private byte[] profilePic;
  4.  
  5. private String user_id;
  6.  
  7. private String profilePicContentType;
  8.  
  9. //getter & setter methods below
  10.  
  11. }
  12.  
  13. @RequestMapping(value = "/images",
  14. method = RequestMethod.POST,
  15. produces = MediaType.APPLICATION_JSON_VALUE)
  16. @Timed
  17. public ResponseEntity<Image> createImage(@RequestBody Image image) throws URISyntaxException {
  18. log.debug("REST request to save Image : {}", image);
  19. if (image.getId() != null) {
  20. return ResponseEntity.badRequest().headers(HeaderUtil.createFailureAlert("image", "idexists", "A new image cannot already have an ID")).body(null);
  21. }
  22. Image result = imageService.save(image);
  23. return ResponseEntity.created(new URI("/api/images/" + result.getId()))
  24. .headers(HeaderUtil.createEntityCreationAlert("image", result.getId().toString()))
  25. .body(result);
  26. }
  27.  
  28. <div class="btn btn-primary" ngf-select ng-model="vm.settingsAccount.profilePic" name="file" ngf-pattern="'image/*'"
  29. ngf-accept="'image/*'" ngf-max-size="16MB" ngf-min-height="100"
  30. ngf-resize="{width: 100, height: 100}">Select</div>
  31.  
  32. var imageDomain = function (settingsAccount){
  33. return {
  34. profilePic: settingsAccount.profilePic,
  35. user_id : settingsAccount.login,
  36. profile_pic_content_type : 'UTF-8'
  37. }
  38. }
  39.  
  40. function save(){
  41. vm.image = imageDomain(vm.settingsAccount);
  42. ImageService.update(vm.image);
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement