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


Java BlobKey.getKeyString方法代码示例

本文整理汇总了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();
	}
 
开发者ID:Laesod,项目名称:binary-storage,代码行数:26,代码来源:BinaryStorageBOInBlobStoreGAEImpl.java

示例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;
    }
}
 
开发者ID:TEAMMATES,项目名称:teammates,代码行数:19,代码来源:ImageUploadAction.java

示例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));
}
 
开发者ID:zach-m,项目名称:gae-jersey-guice-jsf,代码行数:39,代码来源:GaeBlobServlet.java

示例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;
    }
}
 
开发者ID:TEAMMATES,项目名称:teammates,代码行数:14,代码来源:StudentProfilePictureUploadAction.java

示例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;
    }
}
 
开发者ID:TEAMMATES,项目名称:teammates,代码行数:16,代码来源:AdminEmailGroupReceiverListUploadAction.java

示例6: serializeId

import com.google.appengine.api.blobstore.BlobKey; //导入方法依赖的package包/类
@Override
protected String serializeId(BlobKey id) {
  return id.getKeyString();
}
 
开发者ID:ArloJamesBarnes,项目名称:walkaround,代码行数:5,代码来源:ThumbnailDirectory.java

示例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.");
    	}
    }
}
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:62,代码来源:BinaryFileUploadServlet.java

示例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);
}
 
开发者ID:TEAMMATES,项目名称:teammates,代码行数:54,代码来源:AdminEmailGroupReceiverListUploadAction.java

示例9: getKeyString

import com.google.appengine.api.blobstore.BlobKey; //导入方法依赖的package包/类
public String getKeyString() {
  BlobKey k = getKey();
  return k == null ? null : k.getKeyString();
}
 
开发者ID:mwl,项目名称:gwt-upload,代码行数:5,代码来源:FilesApiFileItemFactory.java


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