• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java BlobstoreInputStream类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.appengine.api.blobstore.BlobstoreInputStream的典型用法代码示例。如果您正苦于以下问题:Java BlobstoreInputStream类的具体用法?Java BlobstoreInputStream怎么用?Java BlobstoreInputStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BlobstoreInputStream类属于com.google.appengine.api.blobstore包,在下文中一共展示了BlobstoreInputStream类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getFontFromBlobstore

import com.google.appengine.api.blobstore.BlobstoreInputStream; //导入依赖的package包/类
/**
 * Get Font From Blobstore
 * @param blobKey
 * @return font
 * @throws ServletException
 */
private Font getFontFromBlobstore(BlobKey blobKey) throws ServletException{
	try {
		
		//FileService fileService = FileServiceFactory.getFileService();
        //AppEngineFile fontFile = fileService.getBlobFile(blobKey);
        //FileReadChannel readChannel = fileService.openReadChannel(fontFile, false);
        //BufferedReader reader = new BufferedReader(Channels.newReader(readChannel, "UTF8"));
        //InputStream is = Channels.newInputStream(readChannel);
		
		//BlobstoreInputStream is much faster than the above AppEngineFile
    	Font font = FontUtils.getFonts(new BlobstoreInputStream(blobKey))[0];
    	memcache.put(blobKey, font);
    	return font;
	} catch (IOException ex){
		throw new ServletException(ex);
	}
}
 
开发者ID:flyakite,项目名称:fonten,代码行数:24,代码来源:FontSubsetter.java


示例2: getBlobstoreBytes

import com.google.appengine.api.blobstore.BlobstoreInputStream; //导入依赖的package包/类
private byte[] getBlobstoreBytes(String blobKeyString) throws BlobReadException {
  BlobKey blobKey = new BlobKey(blobKeyString);
  if (blobKey == null) {
    throw new BlobReadException("Could not find BlobKey for " + blobKeyString);
  }
  try {
    InputStream blobInputStream = new BlobstoreInputStream(blobKey);
    return ByteStreams.toByteArray(blobInputStream);
  } catch (IOException e) {
    throw new BlobReadException(e, "Error trying to read blob from " + blobKey);
  }
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:13,代码来源:ObjectifyStorageIo.java


示例3: renameFileToGoogleId

import com.google.appengine.api.blobstore.BlobstoreInputStream; //导入依赖的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: testBlobInputStream

import com.google.appengine.api.blobstore.BlobstoreInputStream; //导入依赖的package包/类
@Test
public void testBlobInputStream() throws Exception {
    String CONTENT = "BlobInputStreamTest";
    BlobKey blobKey = writeNewBlobFile(CONTENT);

    BlobstoreInputStream stream = new BlobstoreInputStream(blobKey);
    assertEquals(CONTENT, toString(stream));
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:9,代码来源:BlobInputStreamTest.java


示例5: testBlobInputStreamWithOffset

import com.google.appengine.api.blobstore.BlobstoreInputStream; //导入依赖的package包/类
@Test
public void testBlobInputStreamWithOffset() throws Exception {
    BlobKey blobKey = writeNewBlobFile("BlobInputStreamTest");

    int OFFSET = 4;
    BlobstoreInputStream stream = new BlobstoreInputStream(blobKey, OFFSET);
    assertEquals("InputStreamTest", toString(stream));
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:9,代码来源:BlobInputStreamTest.java


示例6: doPost

import com.google.appengine.api.blobstore.BlobstoreInputStream; //导入依赖的package包/类
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
		throws ServletException, IOException {

	String password = req.getParameter("password");
	Map<String, List<BlobKey>> uploads = blobstoreService.getUploads(req);
	
	if (!uploads.containsKey("file")) {
		sendError(resp, 400, "No certificate file");
		return;
	}
	
	BlobKey key = uploads.get("file").get(0);

	if (!signatureContainerService.isValid(new BlobstoreInputStream(key), password)) {
		signatureContainerDescriptionRepository.delete(getUserId(req));
		sendError(resp, 400, "Wrong password or file");
		return;
	}
	
	if (!checkMasterPermission(req)) {
		sendError(resp, 403, "Wrong permissions");
		return;
	}
	
	signatureContainerDescriptionRepository.store(new SignatureContainerDescription(
			key, 
			password, 
			isMaster(req) ? "master" : getUserId(req)));
}
 
开发者ID:aleksz,项目名称:driveddoc,代码行数:31,代码来源:OCSPSignatureContainerServlet.java


示例7: toString

import com.google.appengine.api.blobstore.BlobstoreInputStream; //导入依赖的package包/类
private String toString(BlobstoreInputStream in) throws IOException {
    byte[] contents = IOUtils.toBytes(in, true);
    return new String(contents);
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:5,代码来源:BlobInputStreamTest.java


示例8: getContent

import com.google.appengine.api.blobstore.BlobstoreInputStream; //导入依赖的package包/类
public InputStream getContent(SignatureContainerDescription description) throws IOException {
	return new BlobstoreInputStream(description.getKey());
}
 
开发者ID:aleksz,项目名称:driveddoc,代码行数:4,代码来源:SignatureContainerDescriptionRepository.java


示例9: structureFileAndPostToDb

import com.google.appengine.api.blobstore.BlobstoreInputStream; //导入依赖的package包/类
/**
 * @return
 * @throws IOException
 */
private boolean structureFileAndPostToDb() throws IOException {

    /* Define the File API specific instances */
    BlobstoreService blobStoreService = BlobstoreServiceFactory.getBlobstoreService();
    FileService fileService = FileServiceFactory.getFileService();

    /* */
    final AppEngineFile blobFile = fileService.createNewBlobFile(dataWhole.getMimeType(), dataWhole.getFileName());

    /* */
    final FileWriteChannel writeChannel = fileService.openWriteChannel(blobFile, true);

    /* */
    Boolean transaction = ofy().transact(new Work<Boolean>() {
        @Override
        public Boolean run() {
            dataPieces = ofy().load().keys(dataWhole.getDataPieceKeyList());
            return dataPieces.size() > 0 ? true : false;
        }
    });

    if (transaction) {

        int length;
        byte[] buffer = new byte[1024000];

        for (int i = 1; i <= dataPieces.size(); i++) {

            Key<DataPiece> pieceKey = Key.create(Key.create(DataWhole.class, dataWhole.getKey()), DataPiece.class,
                    dataWhole.getKey() + i);

            DataPiece dataPiece = dataPieces.get(pieceKey);

            logger.log(Level.INFO, "DataPiece Blobkey is " + dataPiece.getBlobKey());
            BlobstoreInputStream blobStream = new BlobstoreInputStream(dataPiece.getBlobKey());

            while ((length = blobStream.read(buffer)) != -1) {
                writeChannel.write(ByteBuffer.wrap(buffer, 0, length));
            }

            blobStream.close();
            blobStoreService.delete(dataPiece.getBlobKey());
        }

        writeChannel.closeFinally();

        dataWhole.setBlobKey(fileService.getBlobKey(blobFile));

        logger.log(Level.INFO, "New Blobkey is " + fileService.getBlobKey(blobFile));
        
        /* Remove the pieces once it has been successfully restructured */
        for (DataPiece piece : dataPieces.values()) {
            blobStoreService.delete(piece.getBlobKey());
        }

        Boolean dwTransaction = ofy().transact(new Work<Boolean>() {
            @Override
            public Boolean run() {
                /* Persist the modified DataWhole */
                dataWhole.setDataPieceKeyList(new ArrayList<Key<DataPiece>>());
                ofy().save().entity(dataWhole).now();

                /* Remove the DataWhole's children */
                ofy().delete().entities(dataPieces.values()).now();

                return true;
            }
        });

        return dwTransaction;
    }

    return false;

}
 
开发者ID:lolletsoc,项目名称:dissertation-project,代码行数:80,代码来源:FileJoinerBackend.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java NodeId类代码示例发布时间:2022-05-22
下一篇:
Java RecyclerItemCallback类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap