Search in sources :

Example 6 with BlobInfo

use of com.google.appengine.api.blobstore.BlobInfo in project teammates by TEAMMATES.

the class StudentProfilePictureUploadAction method extractProfilePictureKey.

private BlobInfo extractProfilePictureKey() {
    try {
        Map<String, List<BlobInfo>> blobsMap = BlobstoreServiceFactory.getBlobstoreService().getBlobInfos(request);
        List<BlobInfo> blobs = blobsMap.get(Const.ParamsNames.STUDENT_PROFILE_PHOTO);
        if (blobs == null || blobs.isEmpty()) {
            statusToUser.add(new StatusMessage(Const.StatusMessages.STUDENT_PROFILE_NO_PICTURE_GIVEN, StatusMessageColor.DANGER));
            isError = true;
            return null;
        }
        BlobInfo profilePic = blobs.get(0);
        return validateProfilePicture(profilePic);
    } catch (IllegalStateException e) {
        /*
             * This means the action was called directly (and not via BlobStore API callback).
             * Simply redirect to ProfilePage.
             */
        return null;
    }
}
Also used : List(java.util.List) BlobInfo(com.google.appengine.api.blobstore.BlobInfo) StatusMessage(teammates.common.util.StatusMessage)

Aggregations

BlobInfo (com.google.appengine.api.blobstore.BlobInfo)6 List (java.util.List)4 BlobKey (com.google.appengine.api.blobstore.BlobKey)3 IOException (java.io.IOException)2 StatusMessage (teammates.common.util.StatusMessage)2 BlobstoreFailureException (com.google.appengine.api.blobstore.BlobstoreFailureException)1 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)1 AppUrl (teammates.common.util.AppUrl)1 AdminEmailComposePageData (teammates.ui.pagedata.AdminEmailComposePageData)1 FileUploadPageData (teammates.ui.pagedata.FileUploadPageData)1