@RequestMapping(value="/uploadgift", method=RequestMethod.POST)
    public ModelAndView uploadGift(@RequestParam("title") String title, @RequestParam("desc") String desc,
    		@RequestParam("img") MultipartFile file) {
		logger.info("/uploadgift POST method is called");
		Gift gift = new Gift(title, desc);
		
		// get current user, in order to set the owner of this gift
		String curUserName = getCurrentUserName();
		gift.setOwner(curUserName);
		
		// save will do setId, setDataUrl. 
		// if there is no image, still dataUrl=ROOT_PATH+id+original_name, but this file does not actually exist.
        
        ModelAndView model = new ModelAndView();
        model.addObject("title", title);
        model.setViewName("uploadsuccess");
        if (!file.isEmpty()) {
            try {
                byte[] bytes = file.getBytes();
                String oriFileName = file.getOriginalFilename();
                gift.setOriName(oriFileName);
                save(gift);
 
                // Creating the directory to store file
                File dir = new File(GIFT_STORE_PATH);
                if (!dir.exists())
                    dir.mkdirs();
                logger.info("dir="+dir.getAbsolutePath());
 
                // Create the file on server
                String giftAbsPath = getGiftAbsPath(gift);
                File serverFile = new File(giftAbsPath);
                BufferedOutputStream stream = new BufferedOutputStream(
                        new FileOutputStream(serverFile));
                stream.write(bytes);
                stream.close();
 
                logger.info("Server File Location="
                        + serverFile.getAbsolutePath());
                
                File voteFile = new File(gift.getVotedUserUrl());
                gift.saveVotedUser();
                logger.info("Vote user file location=" + voteFile.getAbsolutePath());
                
                model.addObject("message", "Upload successful!");
                return model;
            } catch (Exception e) {
                model.addObject("message", "Upload failed => " + e.getMessage());
                return model;
            }
        } else {
        	save(gift);
            model.addObject("message", "Uploaded without an image");
            return model;
        }
    }