Package com.google.appengine.api.blobstore

Examples of com.google.appengine.api.blobstore.BlobKey


public class ShowController extends Controller {

    @Override
    public Navigation run() throws Exception {
        String keyName = asString("keyName");
        BlobKey blobKey = new BlobKey(keyName);
        BlobstoreService bs = BlobstoreServiceFactory.getBlobstoreService();
        bs.serve(blobKey, response);
        return null;
    }
View Full Code Here


public class DeleteController extends Controller {

    @Override
    public Navigation run() throws Exception {
        String keyName = asString("keyName");
        BlobKey blobKey = new BlobKey(keyName);
        BlobstoreService bs = BlobstoreServiceFactory.getBlobstoreService();
        bs.delete(blobKey);
        Datastore.delete(Datastore.createKey(Blobstore.class, keyName));
        return redirect(basePath);
    }
View Full Code Here

   
    @Override
    public BlobKey decode(JsonReader reader, BlobKey defaultValue) {
        String text = reader.read();
        if(text != null){
            return new BlobKey(text);
        }
        return defaultValue;
    }
View Full Code Here

    public void modelToJson() throws Exception {
        AppEngineTypeListAttrsModel m = new AppEngineTypeListAttrsModel();
        m.setEmailListAttr(Arrays.asList(new Email("a@b.com"), new Email(
            "d@e.com")));
        m.setBlobKeyListAttr(Arrays.asList(
            new BlobKey("lkwejl2k3jrksl"),
            new BlobKey("kaekl23joij")));
        m.setBlobListAttr(Arrays.asList(new Blob("hello".getBytes()), new Blob(
            "world".getBytes())));
        m.setCategoryListAttr(Arrays.asList(
            new Category("partOfSpeech"),
            new Category("kind")));
View Full Code Here

                    .asList(new Email("a@b.com"), new Email("d@e.com"))
                    .toArray(),
                m.getEmailListAttr().toArray());
        Assert.assertArrayEquals(
            Arrays.asList(
                new BlobKey("lkwejl2k3jrksl"),
                new BlobKey("kaekl23joij")).toArray(),
            m.getBlobKeyListAttr().toArray());
        Assert.assertArrayEquals(
            Arrays.asList(
                new Blob("hello".getBytes()),
                new Blob("world".getBytes())).toArray(),
View Full Code Here

                return "slim3-gen";
            }
        });
        AppEngineTypeAttrsModel m = new AppEngineTypeAttrsModel();
        m.setKey(KeyFactory.createKey("test", 1000));
        m.setBlobKeyAttr(new BlobKey("Q3PqkweYlb4iWpp0BVw"));
        m.setCategoryAttr(new Category("partOfSpeech"));
        m.setEmailAttr(new Email("takawitter@test.com"));
        m.setBlobAttr(new Blob("hello".getBytes()));
        m.setGeoPtAttr(new GeoPt(10, 10));
        m.setImHandleAttr1(new IMHandle(IMHandle.Scheme.xmpp, "handle"));
View Full Code Here

    @Test
    public void nullCheck() {
        assertNull(new Blob(null).getBytes());
        try {
            new BlobKey(null);
            fail();
        } catch (IllegalArgumentException e) {
        }
        try {
            new Category(null);
View Full Code Here

  @Override
  public Boolean deleteResource(ResourceSummaryDTO dto) {
    try {
      Resource resource = DatastoreProxy.getResourceById(dto.getId());
      if (resource != null) {
        BlobstoreServiceFactory.getBlobstoreService().delete(new BlobKey(resource.getBlobKey()));
        DatastoreProxy.deleteResource(resource.getId());
        return true;
      }
      return false;
    } catch (Exception e) {
View Full Code Here

  private BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();

  public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {

    Map<String, BlobKey> blobs = blobstoreService.getUploadedBlobs(req);
    BlobKey blobKey = blobs.get("imageUploader");
    log.info("BlobKey: " + blobKey);
    if (blobKey != null) {
      String imageUrl = ImagesServiceFactory.getImagesService().getServingUrl(blobKey);
      String keyString = blobKey.getKeyString();
      if (ServletHelper.isDevMode()) {
        imageUrl = imageUrl.replace("http://0.0.0.0:", "http://127.0.0.1:");
      }     
      res.sendRedirect("/adware/uploadService?url=" + imageUrl + "&key=" + keyString);
View Full Code Here

        try {
          log.info("Entering deletion task for orphan blob with key=" + blobKey);
          log.info("Sleeping " + blobThreadSleep + " milliseconds...");
          Thread.sleep(blobThreadSleep);
          log.info("Wake up!");
          BlobstoreServiceFactory.getBlobstoreService().delete(new BlobKey(blobKey));
          log.info("Successfully delete orphan blob with key=" + blobKey);
        } catch (BlobstoreFailureException e) {
          log.severe("Could not delete blob with key=" + blobKey);
          DatastoreProxy.createOrphantBlob(new OrphanBlob(blobKey));
          log.info("Created a corresponding OrphanBlob object.");
View Full Code Here

TOP

Related Classes of com.google.appengine.api.blobstore.BlobKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.