@@ -0,0 +1,3255 @@
+package com.example.photo;%0A%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.stereotype.Controller;%0Aimport org.springframework.web.bind.annotation.*;%0Aimport javax.servlet.http.HttpServletRequest;%0Aimport javax.servlet.http.HttpServletResponse;%0Aimport org.springframework.web.servlet.ModelAndView;%0Aimport org.springframework.web.multipart.MultipartFile;%0Aimport org.springframework.web.servlet.view.RedirectView;%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.util.*;%0A%0A@Controller%0Apublic class PhotoController %7B%0A%0A    @Autowired%0A    S3Service s3Client;%0A%0A    @Autowired%0A    AnalyzePhotos photos;%0A%0A    @Autowired%0A    WriteExcel excel ;%0A%0A    @Autowired%0A    SendMessages sendMessage;%0A%0A    @GetMapping(%22/%22)%0A    public String root() %7B%0A        return %22index%22;%0A    %7D%0A%0A    @GetMapping(%22/process%22)%0A    public String process() %7B%0A        return %22process%22;%0A    %7D%0A%0A    @GetMapping(%22/photo%22)%0A    public String photo() %7B%0A        return %22upload%22;%0A    %7D%0A%0A%0A%0A    @RequestMapping(value = %22/getimages%22, method = RequestMethod.GET)%0A    @ResponseBody%0A    String getImages(HttpServletRequest request, HttpServletResponse response) %7B%0A%0A    return s3Client.ListAllObjects(%22scottphoto%22);%0A    %7D%0A%0A%0A    // generates a report that analyzes photos in a given bucket%0A    @RequestMapping(value = %22/report%22, method = RequestMethod.POST)%0A    @ResponseBody%0A    String report(HttpServletRequest request, HttpServletResponse response) %7B%0A%0A        String email = request.getParameter(%22email%22);%0A%0A       // Get a list of key names in the given bucket%0A       List myKeys =  s3Client.ListBucketObjects(%22scottphoto%22);%0A%0A       // Create a List to store the data%0A       List myList = new ArrayList%3CList%3E();%0A%0A       // loop through each element in the List%0A       int len = myKeys.size();%0A       for (int z=0 ; z %3C len; z++) %7B%0A%0A           String key = (String) myKeys.get(z);%0A           byte%5B%5D keyData = s3Client.getObjectBytes (%22scottphoto%22, key);%0A           //myMap.put(key, keyData);%0A%0A           //Analyze the photo%0A          ArrayList item =  photos.DetectLabels(keyData, key);%0A          myList.add(item);%0A       %7D%0A%0A       // Now we have a list of WorkItems that have all of the analytical data describing the photos in the S3 bucket%0A       InputStream excelData = excel.exportExcel(myList);%0A%0A       try %7B%0A           //email the report%0A           sendMessage.sendReport(excelData, email);%0A%0A       %7D catch (Exception e) %7B%0A%0A           e.printStackTrace();%0A       %7D%0A        return %22The photos have been analyzed and the report is sent%22;%0A    %7D%0A%0A    //Upload an image to send to a S3 bucket%0A    @RequestMapping(value = %22/upload%22, method = RequestMethod.POST)%0A    @ResponseBody%0A    public ModelAndView singleFileUpload(@RequestParam(%22file%22) MultipartFile file) %7B%0A%0A        try %7B%0A%0A            // Now i can add this to an S3 Bucket%0A            byte%5B%5D bytes = file.getBytes();%0A            String name =  file.getOriginalFilename() ;%0A%0A           // Put the file into the bucket%0A            s3Client.putObject(bytes, %22scottphoto%22, name);%0A       //     return %22You have placed %22 +name + %22 into the S3 bucket%22;%0A        %7D catch (IOException e) %7B%0A            e.printStackTrace();%0A        %7D%0A        return new ModelAndView(new RedirectView(%22photo%22));%0A    %7D%0A%7D%0A%0A%0A

Create PhotoController.java