本文整理汇总了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;
}
}
示例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;
}
示例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);
}
示例4: blobInfoToFileData
import com.google.appengine.api.blobstore.BlobInfo; //导入方法依赖的package包/类
public static FileData blobInfoToFileData(BlobInfo blobInfo) {
return new FileData(blobInfo.getFilename(), blobInfo.getBlobKey());
}
示例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);
}