Search in sources :

Example 1 with FileUploadPageData

use of teammates.ui.pagedata.FileUploadPageData in project teammates by TEAMMATES.

the class ImageUploadAction method prepareData.

protected FileUploadPageData prepareData() {
    FileUploadPageData data = new FileUploadPageData(account, sessionToken);
    BlobInfo blobInfo = extractImageKey(getImageKeyParam());
    if (blobInfo == null) {
        data.isFileUploaded = false;
        data.fileSrcUrl = null;
        log.warning("Image Upload Failed");
        statusToAdmin = "Image Upload Failed";
        return data;
    }
    BlobKey blobKey = blobInfo.getBlobKey();
    data.isFileUploaded = true;
    AppUrl fileSrcUrl = Config.getAppUrl(Const.ActionURIs.PUBLIC_IMAGE_SERVE).withParam(Const.ParamsNames.BLOB_KEY, blobKey.getKeyString());
    String absoluteFileSrcUrl = fileSrcUrl.toAbsoluteString();
    data.fileSrcUrl = fileSrcUrl.toString();
    log.info("New Image Uploaded : " + absoluteFileSrcUrl);
    statusToAdmin = "New Image Uploaded : " + "<a href=" + data.fileSrcUrl + " target=\"_blank\">" + absoluteFileSrcUrl + "</a>";
    data.ajaxStatus = "Image Successfully Uploaded to Google Cloud Storage";
    return data;
}
Also used : BlobKey(com.google.appengine.api.blobstore.BlobKey) AppUrl(teammates.common.util.AppUrl) BlobInfo(com.google.appengine.api.blobstore.BlobInfo) FileUploadPageData(teammates.ui.pagedata.FileUploadPageData)

Example 2 with FileUploadPageData

use of teammates.ui.pagedata.FileUploadPageData in project teammates by TEAMMATES.

the class AdminEmailImageUploadAction method execute.

@Override
protected ActionResult execute() {
    gateKeeper.verifyAdminPrivileges(account);
    FileUploadPageData uploadPageData = prepareData();
    AdminEmailComposePageData data = new AdminEmailComposePageData(account, sessionToken);
    data.isFileUploaded = uploadPageData.isFileUploaded;
    data.fileSrcUrl = uploadPageData.fileSrcUrl;
    data.ajaxStatus = uploadPageData.ajaxStatus;
    return createAjaxResult(data);
}
Also used : AdminEmailComposePageData(teammates.ui.pagedata.AdminEmailComposePageData) FileUploadPageData(teammates.ui.pagedata.FileUploadPageData)

Aggregations

FileUploadPageData (teammates.ui.pagedata.FileUploadPageData)2 BlobInfo (com.google.appengine.api.blobstore.BlobInfo)1 BlobKey (com.google.appengine.api.blobstore.BlobKey)1 AppUrl (teammates.common.util.AppUrl)1 AdminEmailComposePageData (teammates.ui.pagedata.AdminEmailComposePageData)1