本文整理汇总了Java中com.google.appengine.api.blobstore.BlobstoreServiceFactory.getBlobstoreService方法的典型用法代码示例。如果您正苦于以下问题:Java BlobstoreServiceFactory.getBlobstoreService方法的具体用法?Java BlobstoreServiceFactory.getBlobstoreService怎么用?Java BlobstoreServiceFactory.getBlobstoreService使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.appengine.api.blobstore.BlobstoreServiceFactory
的用法示例。
在下文中一共展示了BlobstoreServiceFactory.getBlobstoreService方法的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());
}
}
示例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/");
}
示例3: 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();
}
}
}
示例4: 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+"\"}";
}
示例5: 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+"\"}";
}
示例6: 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);
}
示例7: 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);
}
}
示例8: 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);
}
示例9: 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);
}
示例10: 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);
}
}
示例11: getUploadUrl
import com.google.appengine.api.blobstore.BlobstoreServiceFactory; //导入方法依赖的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));
}
示例12: getPictureUploadUrl
import com.google.appengine.api.blobstore.BlobstoreServiceFactory; //导入方法依赖的package包/类
@GET
@Consumes({ MediaType.APPLICATION_JSON })
@Path("/pictureUrl/gameId/{gameId}")
public String getPictureUploadUrl(@HeaderParam("Authorization") String token,
@PathParam("gameId") Long gameId,
@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("/uploadGameContent/gameThumbnail" + "?gameId=" + gameId);
return "{ \"uploadUrl\": \""+url+"\"}";
}
示例13: getHeaderUploadUrl
import com.google.appengine.api.blobstore.BlobstoreServiceFactory; //导入方法依赖的package包/类
@GET
@Consumes({ MediaType.APPLICATION_JSON })
@Path("/headerUrl/gameId/{gameId}")
public String getHeaderUploadUrl(@HeaderParam("Authorization") String token,
@PathParam("gameId") Long gameId,
@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("/uploadGameContent/gameMessagesHeader" + "?gameId=" + gameId);
return "{ \"uploadUrl\": \""+url+"\"}";
}
示例14: getSplashUploadUrl
import com.google.appengine.api.blobstore.BlobstoreServiceFactory; //导入方法依赖的package包/类
@GET
@Consumes({ MediaType.APPLICATION_JSON })
@Path("/splashUrl/gameId/{gameId}")
public String getSplashUploadUrl(@HeaderParam("Authorization") String token,
@PathParam("gameId") Long gameId,
@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("/uploadGameContent/gameSplashScreen" + "?gameId=" + gameId);
return "{ \"uploadUrl\": \""+url+"\"}";
}
示例15: getPictureUploadUrl
import com.google.appengine.api.blobstore.BlobstoreServiceFactory; //导入方法依赖的package包/类
@GET
@Consumes({ MediaType.APPLICATION_JSON })
@Path("/pictureUrl/gameId/{gameIdentifier}/generalItem/{itemId}/{key}")
public String getPictureUploadUrl(@HeaderParam("Authorization") String token,
@PathParam("gameIdentifier") Long gameId,
@PathParam("itemId") Long itemId,
@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("/uploadGameContent/generalItems/"+itemId+"/"+key + "?gameId=" + gameId);
return "{ \"uploadUrl\": \""+url+"\"}";
}