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


Java BlobstoreService类代码示例

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


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

示例1: attemptGetImageMetadata

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

import com.google.appengine.api.blobstore.BlobstoreService; //导入依赖的package包/类
public static void serveFileFromCloudStorage(String bucketName,
                                             String objectName,
                                             String contentType,
                                             HttpServletResponse resp) throws IOException {

    // GcsFilename fileName = getFileName(req);
    GcsFilename fileName = new GcsFilename(bucketName, objectName);

    // resp.setContentType("video/webm");
    resp.setContentType(contentType);

    if (SERVE_USING_BLOBSTORE_API) {
        BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
        BlobKey blobKey = blobstoreService.createGsBlobKey(
                "/gs/" + fileName.getBucketName() + "/" + fileName.getObjectName());
        blobstoreService.serve(blobKey, resp);
    } else {
        GcsInputChannel readChannel = gcsService.openPrefetchingReadChannel(fileName, 0, BUFFER_SIZE);
        copy(Channels.newInputStream(readChannel), resp.getOutputStream());
    }
}
 
开发者ID:Cryptonomica,项目名称:cryptonomica,代码行数:22,代码来源:CloudStorageService.java

示例3: assignBlobKey

import com.google.appengine.api.blobstore.BlobstoreService; //导入依赖的package包/类
/**
 * Returns a new blobkey for an uploaded blob.
 * If no blob was uploaded, then null is returned.
 * @param req
 * 			: the HTTP Servlet Request from the Servlet
 * @param paramName
 * 			: the name of the HTTP blob parameter
 * @param blobStoreService
 * 			: the blobstore service initialized in the calling servlet
 * @return a new BlobKey for this blob
 */
public static BlobKey assignBlobKey(HttpServletRequest req, String paramName, 
		BlobstoreService blobstoreService) {
       java.util.Map<String, List<BlobKey>> blobs = blobstoreService.getUploads(req);
       List<BlobKey> blobKeys = blobs.get(paramName);
       if (blobKeys != null) {
       	BlobKey blobKey = blobKeys.get(0);
           final BlobInfo blobInfo = new BlobInfoFactory().loadBlobInfo(blobKey);
           if (blobKey != null) {
           	if (blobInfo.getSize() > 0) {
           		return blobKey;
           	}
           	else {
           		blobstoreService.delete(blobKey);
           		return null;
           	}
           }
           else {
           	return null;
           }
	}
       else {
       	return null;
       }
}
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:36,代码来源:BlobUtils.java

示例4: doGet

import com.google.appengine.api.blobstore.BlobstoreService; //导入依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
		throws ServletException, IOException {
	Long id = new RequestParam(req).getLong("id");
	if (null == id) {
		resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
		return;
	}

	PersistenceManager pm = PMF.get().getPersistenceManager();
	try {
		Resource resource = pm.getObjectById(Resource.class, id);
		BlobKey blobKey = resource.getBlobKey();
		pm.deletePersistent(resource);

		BlobstoreService service = BlobstoreServiceFactory
				.getBlobstoreService();
		service.delete(blobKey);
	} catch (Exception e) {
		LOGGER.warning(e.getMessage());
	} finally {
		pm.close();
	}

	resp.sendRedirect("/admin/resource/");
}
 
开发者ID:santiagolizardo,项目名称:jerba,代码行数:27,代码来源:DeleteResourceServlet.java

示例5: run

import com.google.appengine.api.blobstore.BlobstoreService; //导入依赖的package包/类
@Override
public void run() {
	BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
	PersistenceManager pm = PMF.get().getPersistenceManager();
	for (Iterator<FilePathJDO> iterator = FilePathManager.getFilePathJDOs(pm, getFullAccount(), getRunId(), null, null).iterator(); iterator.hasNext();) {               //TODO check if this deletion works and iff fullAccount is not an email but 1:123
		FilePathJDO fpjdo = (FilePathJDO) iterator.next();
		try {
			blobstoreService.delete(fpjdo.getBlobKey());
			pm.deletePersistent(fpjdo);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
	
}
 
开发者ID:WELTEN,项目名称:dojo-ibl,代码行数:17,代码来源:DeleteBlobs.java

示例6: getUploadUrl

import com.google.appengine.api.blobstore.BlobstoreService; //导入依赖的package包/类
@GET
	@Consumes({ MediaType.APPLICATION_JSON })
	@Path("/url/account/{account}/{key}")
	public String getUploadUrl(@HeaderParam("Authorization") String token,
							   @PathParam("account") String account,
							   @PathParam("key") String key,
							   @DefaultValue("application/json") @HeaderParam("Content-Type") String contentType,
							   @DefaultValue("application/json") @HeaderParam("Accept") String accept)   {
		if (!validCredentials(token))
			return serialise(getInvalidCredentialsBean(), accept);
		BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
		String url = blobstoreService.createUploadUrl("/uploadUserContent/"+key+"?account=" + account);

//		String url = blobstoreService.createUploadUrl("/uploadGameContent/generalItems/"+itemId+"/"+key + "?runId=" + runId);
		return "{ \"uploadUrl\": \""+url+"\"}";
	}
 
开发者ID:WELTEN,项目名称:dojo-ibl,代码行数:17,代码来源:AccountApi.java

示例7: getUploadUrl

import com.google.appengine.api.blobstore.BlobstoreService; //导入依赖的package包/类
@GET
	@Consumes({ MediaType.APPLICATION_JSON })
	@Path("/url/runId/{runIdentifier}/account/{account}/{key}")
	public String getUploadUrl(@HeaderParam("Authorization") String token,
									  @PathParam("runIdentifier") Long runId,
									  @PathParam("account") String account,
									  @PathParam("key") String key,
									  @DefaultValue("application/json") @HeaderParam("Content-Type") String contentType,
									  @DefaultValue("application/json") @HeaderParam("Accept") String accept)   {
		if (!validCredentials(token))
			return serialise(getInvalidCredentialsBean(), accept);
		BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
		String url = blobstoreService.createUploadUrl("/uploadServiceWithUrl/generalItems?withBlob=true&runId=" + runId + "&account=" + account + "&fileName="+key);

//		String url = blobstoreService.createUploadUrl("/uploadGameContent/generalItems/"+itemId+"/"+key + "?runId=" + runId);
		return "{ \"uploadUrl\": \""+url+"\"}";
	}
 
开发者ID:WELTEN,项目名称:dojo-ibl,代码行数:18,代码来源:ResponseAPI.java

示例8: testlistFiles

import com.google.appengine.api.blobstore.BlobstoreService; //导入依赖的package包/类
@Test
public void testlistFiles() {

  DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
  BlobstoreService blobstore = BlobstoreServiceFactory.getBlobstoreService();

  Blobstoretest blobstoretest = new Blobstoretest(datastore, blobstore);

  List<FileData> savedFiles = generateFiles(10);
  Iterable<Entity> entities = Iterables.transform(savedFiles, fileDataToEntity());    
  datastore.put(entities);
  
  List<FileData> expected = savedFiles.subList(0, 5);
  List<FileData> actual = blobstoretest.listFiles(null, 0, 5);

  assertEquals(expected, actual);
}
 
开发者ID:andrestesti,项目名称:blobstoretest,代码行数:18,代码来源:ApiTest.java

示例9: dispose

import com.google.appengine.api.blobstore.BlobstoreService; //导入依赖的package包/类
@Override
public void dispose() {
    FileService fileService = FileServiceFactory.getFileService();
    IOUtils.closeQuietly(outputStream);
    IOUtils.closeQuietly(inputStream);
    try {
        if(readChannel != null) {
            readChannel.close();
        }
        //fileService.delete(file); non funziona (UnsupportedOperationException)
        BlobKey blobKey = fileService.getBlobKey(file);
        BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
        blobstoreService.delete(blobKey);
    } catch (Exception e) {
        logger.warn("Could not delete temporary file " + file.getFullPath(), e);
    }
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:18,代码来源:GAETempFileService.java

示例10: loadSchema

import com.google.appengine.api.blobstore.BlobstoreService; //导入依赖的package包/类
private void loadSchema(String fileUri, TableSchema schema) throws IOException  {
	// TODO(frew): Move to AnalysisUtility
	String schemaFileUri = fileUri + ".schema";
	String schemaFileName = "/gs/" + schemaFileUri.substring(schemaFileUri.indexOf("//") + 2);
	BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
	BlobKey key = blobstoreService.createGsBlobKey(schemaFileName);
	
	System.out.println("Schema File Name : " + schemaFileName);
	
	String schemaLine = AnalysisUtility.loadSchemaStr(schemaFileName);
	
	String[] schemaFieldStrs = schemaLine.split(",");
	List<TableFieldSchema> schemaFields = new ArrayList<TableFieldSchema>(schemaFieldStrs.length);
	for (String schemaFieldStr : schemaFieldStrs) {
		TableFieldSchema field = new TableFieldSchema();
		String[] schemaFieldStrParts = schemaFieldStr.split(":");
		field.setName(schemaFieldStrParts[0]);
		field.setType(schemaFieldStrParts[1]);
                       field.setMode("NULLABLE");
		schemaFields.add(field);
	}
	
	schema.setFields(schemaFields);
}
 
开发者ID:steveseo,项目名称:l2bq,代码行数:25,代码来源:LoadCloudStorageToBigqueryTask.java

示例11: testCreateGsBlobKey

import com.google.appengine.api.blobstore.BlobstoreService; //导入依赖的package包/类
@Test
@InSequence(100)
public void testCreateGsBlobKey() throws Exception {
    final long ts = System.currentTimeMillis();
    final byte[] bytes = "FooBar".getBytes();

    GcsService service = GcsServiceFactory.createGcsService();
    GcsFilename filename = new GcsFilename("GcsBucket", String.valueOf(ts));
    GcsFileOptions options = new GcsFileOptions.Builder().mimeType(CONTENT_TYPE).build();
    try (GcsOutputChannel out = service.createOrReplace(filename, options)) {
        IOUtils.copy(Channels.newChannel(new ByteArrayInputStream(bytes)), out);
    }

    BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
    BlobKey key =  blobstoreService.createGsBlobKey("/gs/GcsBucket/" + ts);
    byte[] fetched = blobstoreService.fetchData(key, 0, 10);
    Assert.assertArrayEquals(bytes, fetched);
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:19,代码来源:GcsBlobstoreUploadTest.java

示例12: doGet

import com.google.appengine.api.blobstore.BlobstoreService; //导入依赖的package包/类
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    BlobstoreService service = BlobstoreServiceFactory.getBlobstoreService();

    String blobKey = request.getParameter("blobKey");
    ByteRange range = service.getByteRange(request);
    String blobRange = request.getParameter("blobRange");
    String blobRangeString = request.getParameter("blobRangeString");

    BlobKey key = new BlobKey(blobKey);
    if (range != null) {
        service.serve(key, range, response);
    } else if (blobRange != null) {
        service.serve(key, new ByteRange(Long.parseLong(blobRange)), response);
    } else if (blobRangeString != null) {
        service.serve(key, blobRangeString, response);
    } else {
        service.serve(key, response);
    }
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:21,代码来源:BlobserviceServeServlet.java

示例13: AttachmentService

import com.google.appengine.api.blobstore.BlobstoreService; //导入依赖的package包/类
@Inject
public AttachmentService(RawAttachmentService rawService, BlobstoreService blobStore,
    CheckedDatastore datastore, MemcacheTable.Factory memcacheFactory,
    @Flag(FlagName.MAX_THUMBNAIL_SAVED_SIZE_BYTES) int maxThumbnailSavedSizeBytes) {
  this.rawService = rawService;
  this.blobstore = blobStore;
  this.metadataDirectory = new MetadataDirectory(datastore);
  this.metadataCache = memcacheFactory.create(MEMCACHE_TAG);
  this.thumbnailDirectory = new ThumbnailDirectory(datastore);
  this.maxThumbnailSavedSizeBytes = maxThumbnailSavedSizeBytes;
}
 
开发者ID:ArloJamesBarnes,项目名称:walkaround,代码行数:12,代码来源:AttachmentService.java

示例14: RawAttachmentService

import com.google.appengine.api.blobstore.BlobstoreService; //导入依赖的package包/类
@Inject
public RawAttachmentService(BlobstoreService blobstoreService, ImagesService imagesService,
    BlobInfoFactory blobInfoFactory,
    @Flag(FlagName.ATTACHMENT_HEADER_BYTES_UPPER_BOUND) int headerBytesUpperBound,
    RandomBase64Generator random64,
    MetadataDirectory metadataDirectory) {
  this.blobstoreService = blobstoreService;
  this.imagesService = imagesService;
  this.blobInfoFactory = blobInfoFactory;
  this.headerBytesUpperBound = headerBytesUpperBound;
  this.random64 = random64;
  this.metadataDirectory = metadataDirectory;
}
 
开发者ID:ArloJamesBarnes,项目名称:walkaround,代码行数:14,代码来源:RawAttachmentService.java

示例15: getUploadUrl

import com.google.appengine.api.blobstore.BlobstoreService; //导入依赖的package包/类
/**
 * Gets the blob upload url
 *
 * @param user The Google Authenticated User
 */
@ApiMethod(
        name = "moments.uploadUrl",
        path = "moments/uploadUrl",
        httpMethod = HttpMethod.GET
)
public UploadUrlResponse getUploadUrl(User user) throws OAuthRequestException {
    if (userDAO.notRegistered(user)) {
        throw new OAuthRequestException(Messages.ERROR_AUTH);
    }

    BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
    return new UploadUrlResponse().setUploadUrl(blobstoreService.createUploadUrl(Config.BLOB_UPLOAD));
}
 
开发者ID:AndrewJack,项目名称:moment-for-android-wear,代码行数:19,代码来源:MomentEndpoint.java


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