String[] imageData = image.split(",");
try {
byte[] imageBytes = Base64.decode(imageData[imageData.length-1]);
String key = GAEFileService.createFile(MimeTypes.getContentType("me-"+System.currentTimeMillis()), "me-"+System.currentTimeMillis(),imageBytes);
User currentUser = getCurrentUser();
Photo photo = new Photo();
photo.filename = "me-"+System.currentTimeMillis();
photo.owner = currentUser;
response.status = StatusCode.CREATED;
Map map = new HashMap();
map.put("key", key);
String url = Router.reverse("api.Files.serve", map).url;
Image original = photo.new Image();
original.key = key;
original.source = url;
original.height = 100;
original.width = 50;
photo.original = original;
photo.insert();
map = new HashMap();
map.put("id", photo.id);
url = Router.reverse("api.Photos.get", map).url;
response.setHeader("location", url);
renderJSON(gson().toJson(photo));