本文整理汇总了Java中com.google.appengine.api.blobstore.BlobKey.getKeyString方法的典型用法代码示例。如果您正苦于以下问题:Java BlobKey.getKeyString方法的具体用法?Java BlobKey.getKeyString怎么用?Java BlobKey.getKeyString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.appengine.api.blobstore.BlobKey
的用法示例。
在下文中一共展示了BlobKey.getKeyString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveFile
import com.google.appengine.api.blobstore.BlobKey; //导入方法依赖的package包/类
@Override
public String saveFile(InputStream inputStream, HttpServletRequest req) {
Map<String, BlobKey> blobs = blobstoreService.getUploadedBlobs(req);
if (blobs.keySet().isEmpty()) {
throw new RuntimeException("No File found");
}
Iterator<String> names = blobs.keySet().iterator();
String blobName = names.next();
BlobKey blobKey = blobs.get(blobName);
/* BlobInfoFactory blobInfoFactory = new BlobInfoFactory();
BlobInfo blobInfo = blobInfoFactory.loadBlobInfo(blobKey);
String contentType = blobInfo.getContentType();
long size = blobInfo.getSize();
Date creation = blobInfo.getCreation();
String fileName = blobInfo.getFilename();
String title = req.getParameter("title");
String description = req.getParameter("description");
boolean isShared = "public".equalsIgnoreCase(req.getParameter("share"));
*/
return blobKey.getKeyString();
}
示例2: deleteImage
import com.google.appengine.api.blobstore.BlobKey; //导入方法依赖的package包/类
/**
* Deletes the uploaded image.
*/
protected void deleteImage(BlobKey blobKey) {
if (blobKey.equals(new BlobKey(""))) {
return;
}
try {
deleteUploadedFile(blobKey);
} catch (BlobstoreFailureException bfe) {
statusToAdmin = Const.ACTION_RESULT_FAILURE
+ " : Unable to delete picture (possible unused picture with key: "
+ blobKey.getKeyString()
+ " || Error Message: "
+ bfe.getMessage() + Const.EOL;
}
}
示例3: doPost
import com.google.appengine.api.blobstore.BlobKey; //导入方法依赖的package包/类
/**
* a callback handler, invoked by GAE after an upload ended successfully. we use it to analyze what was uploaded and return it to
* the sender in an organized JSON
*/
@Override
public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
{
Map<String, List<BlobKey>> uploads = blobSvc.getUploads(req);
Map<String, List<FileInfo>> infos = blobSvc.getFileInfos(req);
List<UploadRec> uploadRecs = new ArrayList<>(uploads.size());
for (Entry<String, List<BlobKey>> entry : uploads.entrySet())
{
String fieldName = entry.getKey();
BlobKey blobKey = entry.getValue().get(0);
FileInfo info = infos.get(fieldName).get(0);
String contentType = info.getContentType();
final String url;
if (contentType.startsWith("image/"))
url = imgSvc.getServingUrl(ServingUrlOptions.Builder.withBlobKey(blobKey));
else
url = baseUrlOf(req) + BLOB_URI + "?k=" + blobKey.getKeyString();
UploadRec upload = new UploadRec();
upload.setFieldName(fieldName);
upload.setCreatedOn(new Date());
upload.setUrl(url);
upload.setFilename(info.getFilename());
upload.setContentType(contentType);
upload.setSize(info.getSize());
uploadRecs.add(upload);
}
res.setContentType("application/json");
res.getOutputStream().print(Jackson1.propsToJson(uploadRecs));
}
示例4: deletePicture
import com.google.appengine.api.blobstore.BlobKey; //导入方法依赖的package包/类
private void deletePicture(BlobKey blobKey) {
if (blobKey.equals(new BlobKey(""))) {
return;
}
try {
logic.deletePicture(blobKey);
} catch (BlobstoreFailureException bfe) {
statusToAdmin = Const.ACTION_RESULT_FAILURE
+ " : Unable to delete profile picture (possible unused picture with key: "
+ blobKey.getKeyString() + " || Error Message: "
+ bfe.getMessage() + Const.EOL;
}
}
示例5: deleteGroupReceiverListFile
import com.google.appengine.api.blobstore.BlobKey; //导入方法依赖的package包/类
private void deleteGroupReceiverListFile(BlobKey blobKey) {
if (blobKey.equals(new BlobKey(""))) {
return;
}
try {
logic.deleteAdminEmailUploadedFile(blobKey);
} catch (BlobstoreFailureException bfe) {
statusToAdmin = Const.ACTION_RESULT_FAILURE
+ " : Unable to delete group receiver list file (possible unused file with key: "
+ blobKey.getKeyString()
+ " || Error Message: "
+ bfe.getMessage() + Const.EOL;
}
}
示例6: serializeId
import com.google.appengine.api.blobstore.BlobKey; //导入方法依赖的package包/类
@Override
protected String serializeId(BlobKey id) {
return id.getKeyString();
}
示例7: doGet
import com.google.appengine.api.blobstore.BlobKey; //导入方法依赖的package包/类
/**
* Respond to servlet GET requests
*/
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
// Lets check the action required by the jsp
String message = req.getParameter("msg");
String action = req.getParameter("action");
if (message.equals("success")) {
// We return information about the file in JSON format
if (action.equalsIgnoreCase("upload")) {
String type = req.getParameter("type");
String datastoreObjectKeyString =
req.getParameter("datastoreObjectKey");
Key datastoreObjectKey = KeyFactory.stringToKey(datastoreObjectKeyString);
BlobKey fileKey = null;
String fileKeyString = null;
String jsonString = null;
// Check type
if (type.equalsIgnoreCase("audio_music") ||
type.equalsIgnoreCase("audio_voice")) {
StationAudio stationAudio =
StationAudioManager.getStationAudio(datastoreObjectKey);
fileKey = stationAudio.getStationAudioMultimediaContent();
}
else if (type.equalsIgnoreCase("image")) {
StationImage stationImage =
StationImageManager.getStationImage(datastoreObjectKey);
fileKey = stationImage.getStationImageMultimediaContent();
}
fileKeyString = fileKey.getKeyString();
BlobInfoFactory bif = new BlobInfoFactory();
BlobInfo blobInfo = bif.loadBlobInfo(fileKey);
String fileName = blobInfo.getFilename();
jsonString = "{" + "\n" +
"\"datastoreObjectKey\":" + "\"" + datastoreObjectKeyString + "\"," + "\n" +
"\"fileKey\":" + "\"" + fileKeyString + "\"," + "\n" +
"\"fileName\":" + "\"" + fileName + "\"\n" +
"}";
log.info("jsonString: " + jsonString);
resp.setContentType("application/json;charset=UTF-8");
resp.setCharacterEncoding("UTF-8");
resp.getWriter().println(jsonString);
}
else if (action.equals("delete")){
resp.getWriter().println("File deleted successfully.");
}
}
}
示例8: execute
import com.google.appengine.api.blobstore.BlobKey; //导入方法依赖的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);
}
示例9: getKeyString
import com.google.appengine.api.blobstore.BlobKey; //导入方法依赖的package包/类
public String getKeyString() {
BlobKey k = getKey();
return k == null ? null : k.getKeyString();
}