public Response uploadPictureToS3()

in src/main/java/com/amazon/photosharing/rest/ContentService.java [94:129]


    public Response uploadPictureToS3(@Context HttpHeaders httpHeaders,
                                      @FormDataParam("comments") List<String> commentStringList,
                                      @FormDataParam("file") InputStream fileInputStream,
                                      @FormDataParam("file") FormDataContentDisposition disposition ) {
        try {
            Comment [] comments = new Comment[commentStringList.size()];

            int i = 0;
            for (String commentString : commentStringList) {
                Comment comment = new Comment();
                comment.setText(commentString);
                comments[i] = comment;
                i++;
            }

            String userName = _request.getUserPrincipal().getName();

            _logger.info("Username : " + userName);
            _logger.info("Comments: " + comments);

            if (disposition != null) _logger.info("Name: " + disposition.getName());
            if (disposition != null) _logger.info("Filename: " + disposition.getFileName());

            User user = _userFacade.findUser(userName);
            Media media = _facade.uploadPictureToS3(user, disposition.getFileName(), fileInputStream, disposition.getType(), comments);

            MediaResult uploadResult = new MediaResult(media);

            return Response.status(HttpStatus.SC_OK).entity(uploadResult).build();
        }

        catch (IOException exc) {
            _logger.error(exc.toString(), exc);
            return Response.status(HttpStatus.SC_BAD_REQUEST).build();
        }
    }