当前位置: 首页>>代码示例>>Java>>正文


Java BlobInfo.getBlobKey方法代码示例

本文整理汇总了Java中com.google.appengine.api.blobstore.BlobInfo.getBlobKey方法的典型用法代码示例。如果您正苦于以下问题:Java BlobInfo.getBlobKey方法的具体用法?Java BlobInfo.getBlobKey怎么用?Java BlobInfo.getBlobKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.appengine.api.blobstore.BlobInfo的用法示例。


在下文中一共展示了BlobInfo.getBlobKey方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: attemptGetImageMetadata

import com.google.appengine.api.blobstore.BlobInfo; //导入方法依赖的package包/类
@Nullable private Image attemptGetImageMetadata(BlobstoreService blobstore, BlobInfo info) {
  if (info.getSize() == 0) {
    // Special case since it would lead to an IllegalArgumentException below.
    log.info("Empty attachment, can't get image metadata: " + info);
    return null;
  }
  final int readPortion = headerBytesUpperBound;
  BlobKey key = info.getBlobKey();
  byte[] data = blobstore.fetchData(key, 0, readPortion);
  try {
    Image img = ImagesServiceFactory.makeImage(data);
    // Force the image to be processed
    img.getWidth();
    img.getHeight();
    return img;
  } catch (RuntimeException e) {
    log.log(Level.SEVERE, "Problem getting image metadata; ignoring", e);
    return null;
  }
}
 
开发者ID:ArloJamesBarnes,项目名称:walkaround,代码行数:21,代码来源:RawAttachmentService.java

示例2: execute

import com.google.appengine.api.blobstore.BlobInfo; //导入方法依赖的package包/类
@Override
protected ActionResult execute() throws EntityDoesNotExistException {
    gateKeeper.verifyLoggedInUserPrivileges();

    String pictureKey = "";
    BlobKey blobKey = new BlobKey("");
    RedirectResult r = createRedirectResult(Const.ActionURIs.STUDENT_PROFILE_PAGE);

    try {
        BlobInfo blobInfo = extractProfilePictureKey();
        if (!isError) {
            blobKey = blobInfo.getBlobKey();
            pictureKey = renameFileToGoogleId(blobInfo);
            logic.updateStudentProfilePicture(account.googleId, pictureKey);
            statusToUser.add(new StatusMessage(Const.StatusMessages.STUDENT_PROFILE_PICTURE_SAVED,
                                               StatusMessageColor.SUCCESS));
            r.addResponseParam(Const.ParamsNames.STUDENT_PROFILE_PHOTOEDIT, "true");
        }
    } catch (BlobstoreFailureException | IOException bfe) {
        deletePicture(blobKey);
        updateStatusesForBlobstoreFailure();
        isError = true;
    } catch (Exception e) {
        /*
         * This is for other exceptions like EntityNotFound, IllegalState, etc
         * that occur rarely and are handled higher up.
         */
        deletePicture(new BlobKey(pictureKey));
        statusToUser.clear();
        throw e;
    }

    return r;
}
 
开发者ID:TEAMMATES,项目名称:teammates,代码行数:35,代码来源:StudentProfilePictureUploadAction.java

示例3: renameFileToGoogleId

import com.google.appengine.api.blobstore.BlobInfo; //导入方法依赖的package包/类
private String renameFileToGoogleId(BlobInfo blobInfo) throws IOException {
    Assumption.assertNotNull(blobInfo);

    BlobKey blobKey = blobInfo.getBlobKey();
    byte[] imageData = new byte[(int) blobInfo.getSize()];
    try (InputStream blobStream = new BlobstoreInputStream(blobKey)) {
        blobStream.read(imageData);
    }

    deletePicture(blobKey);
    return GoogleCloudStorageHelper.writeImageDataToGcs(account.googleId, imageData);
}
 
开发者ID:TEAMMATES,项目名称:teammates,代码行数:13,代码来源:StudentProfilePictureUploadAction.java

示例4: blobInfoToFileData

import com.google.appengine.api.blobstore.BlobInfo; //导入方法依赖的package包/类
public static FileData blobInfoToFileData(BlobInfo blobInfo) {
  return new FileData(blobInfo.getFilename(), blobInfo.getBlobKey());
}
 
开发者ID:andrestesti,项目名称:blobstoretest,代码行数:4,代码来源:FileDataConverters.java

示例5: execute

import com.google.appengine.api.blobstore.BlobInfo; //导入方法依赖的package包/类
@Override
protected ActionResult execute() {
    gateKeeper.verifyAdminPrivileges(account);

    data = new AdminEmailComposePageData(account, sessionToken);
    BlobInfo blobInfo = extractGroupReceiverListFileKey();

    if (blobInfo == null) {
        data.isFileUploaded = false;
        data.fileSrcUrl = null;

        log.info("Group Receiver List Upload Failed");
        statusToAdmin = "Group Receiver List Upload Failed";
        data.ajaxStatus = "Group receiver list upload failed. Please try again.";
        return createAjaxResult(data);
    }

    try {
        List<List<String>> groupReceiverList =
                GoogleCloudStorageHelper.getGroupReceiverList(blobInfo.getBlobKey());

        // log all email addresses retrieved from the txt file
        int i = 0;

        for (List<String> list : groupReceiverList) {
            for (String str : list) {
                log.info(str + " - " + i + " \n");
                i++;
            }
        }
    } catch (IOException e) {
        data.isFileUploaded = false;
        data.fileSrcUrl = null;

        log.info("Group Receiver List Upload Failed: uploaded file is corrupted");
        statusToAdmin = "Group Receiver List Upload Failed: uploaded file is corrupted";
        data.ajaxStatus = "Group receiver list upload failed: uploaded file is corrupted. "
                          + "Please make sure the txt file contains only email addresses "
                          + "separated by comma";
        deleteGroupReceiverListFile(blobInfo.getBlobKey());
        return createAjaxResult(data);
    }

    BlobKey blobKey = blobInfo.getBlobKey();

    data.groupReceiverListFileKey = blobKey.getKeyString();

    data.isFileUploaded = true;
    statusToAdmin = "New Group Receiver List Uploaded";
    data.ajaxStatus = "Group receiver list successfully uploaded to Google Cloud Storage";

    return createAjaxResult(data);
}
 
开发者ID:TEAMMATES,项目名称:teammates,代码行数:54,代码来源:AdminEmailGroupReceiverListUploadAction.java


注:本文中的com.google.appengine.api.blobstore.BlobInfo.getBlobKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。