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


Java BlobstoreServiceFactory类代码示例

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


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

示例1: serveFileFromCloudStorage

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

示例2: doGet

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

示例3: handle

import com.google.appengine.api.blobstore.BlobstoreServiceFactory; //导入依赖的package包/类
@Override
protected void handle (DeleteResourceRequest input,
		DeleteResourceResponse output) throws Exception {
	ApiValidator.request(input, DeleteResourceRequest.class);
	ApiValidator.accessCode(input.accessCode, "input.accessCode");
	output.session = input.session = SessionValidator
			.lookupCheckAndExtend(input.session, "input.session");

	input.resource = ResourceValidator.lookup(input.resource,
			"input.resource");

	BlobstoreServiceFactory.getBlobstoreService()
			.delete(new BlobKey(input.resource.data.substring(5)));

	ResourceServiceProvider.provide().deleteResource(input.resource);
}
 
开发者ID:billy1380,项目名称:blogwt,代码行数:17,代码来源:DeleteResourceActionHandler.java

示例4: run

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

示例5: getUploadUrl

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

示例6: getUploadUrl

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

示例7: testlistFiles

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

示例8: extractImageKey

import com.google.appengine.api.blobstore.BlobstoreServiceFactory; //导入依赖的package包/类
/**
 * Extracts the image metadata by the passed image key parameter.
 */
protected BlobInfo extractImageKey(String param) {
    try {
        Map<String, List<BlobInfo>> blobsMap = BlobstoreServiceFactory.getBlobstoreService().getBlobInfos(request);
        List<BlobInfo> blobs = blobsMap.get(param);

        if (blobs == null || blobs.isEmpty()) {
            data.ajaxStatus = Const.StatusMessages.NO_IMAGE_GIVEN;
            isError = true;
            return null;
        }

        BlobInfo image = blobs.get(0);
        return validateImage(image);
    } catch (IllegalStateException e) {
        return null;
    }
}
 
开发者ID:TEAMMATES,项目名称:teammates,代码行数:21,代码来源:ImageUploadAction.java

示例9: extractProfilePictureKey

import com.google.appengine.api.blobstore.BlobstoreServiceFactory; //导入依赖的package包/类
private BlobInfo extractProfilePictureKey() {
    try {
        Map<String, List<BlobInfo>> blobsMap = BlobstoreServiceFactory.getBlobstoreService()
                                                                      .getBlobInfos(request);
        List<BlobInfo> blobs = blobsMap.get(Const.ParamsNames.STUDENT_PROFILE_PHOTO);
        if (blobs == null || blobs.isEmpty()) {
            statusToUser.add(new StatusMessage(Const.StatusMessages.STUDENT_PROFILE_NO_PICTURE_GIVEN,
                                               StatusMessageColor.DANGER));
            isError = true;
            return null;
        }
        BlobInfo profilePic = blobs.get(0);
        return validateProfilePicture(profilePic);
    } catch (IllegalStateException e) {
        /*
         * This means the action was called directly (and not via BlobStore API callback).
         * Simply redirect to ProfilePage.
         */
        return null;
    }
}
 
开发者ID:TEAMMATES,项目名称:teammates,代码行数:22,代码来源:StudentProfilePictureUploadAction.java

示例10: extractGroupReceiverListFileKey

import com.google.appengine.api.blobstore.BlobstoreServiceFactory; //导入依赖的package包/类
private BlobInfo extractGroupReceiverListFileKey() {
    try {
        Map<String, List<BlobInfo>> blobsMap = BlobstoreServiceFactory.getBlobstoreService().getBlobInfos(request);
        List<BlobInfo> blobs = blobsMap.get(Const.ParamsNames.ADMIN_EMAIL_GROUP_RECEIVER_LIST_TO_UPLOAD);

        if (blobs == null || blobs.isEmpty()) {
            data.ajaxStatus = Const.StatusMessages.NO_GROUP_RECEIVER_LIST_FILE_GIVEN;
            isError = true;
            return null;
        }

        BlobInfo groupReceiverListFile = blobs.get(0);
        return validateGroupReceiverListFile(groupReceiverListFile);
    } catch (IllegalStateException e) {
        return null;
    }
}
 
开发者ID:TEAMMATES,项目名称:teammates,代码行数:18,代码来源:AdminEmailGroupReceiverListUploadAction.java

示例11: dispose

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

示例12: loadSchema

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

示例13: testCreateGsBlobKey

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

示例14: doGet

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

示例15: getBlobServingUrl

import com.google.appengine.api.blobstore.BlobstoreServiceFactory; //导入依赖的package包/类
/**
 * It will return a dev server serving url for given image url
 * @param url image url
 */
@Override
public String getBlobServingUrl(String url) {
  BlobKey bk = BlobstoreServiceFactory.getBlobstoreService().createGsBlobKey(url);
  String u = null;
  try {
      u = ImagesServiceFactory.getImagesService().getServingUrl(bk);
  } catch (Exception IllegalArgumentException) {
      LOG.info("Could not read blob");
  }
  return u;
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:16,代码来源:GalleryServiceImpl.java


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