Package com.google.appengine.api.blobstore

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


      cal.add(Calendar.DATE, 10);
      res.setHeader("Cache-Control", "public, max-age=86400");
      res.setHeader("Expires", cal.getTime().toString());
      if (req.getParameter("key") != null
          && req.getParameter("size") != null) {
        BlobKey blobKey = new BlobKey(req.getParameter("key"));
        ImagesService imagesService = ImagesServiceFactory
            .getImagesService();
        res.sendRedirect(imagesService.getServingUrl(blobKey) + "=s"
            + req.getParameter("size"));
      } else {
View Full Code Here


      val = new Email((String) value);
    } else if (valueType.equals(IMHANDLE)) {
      String[] split = ((String) value).split(" ");
      val = new IMHandle(Scheme.valueOf(split[0]), split[1]);
    } else if (valueType.equals(BLOB_KEY)) {
      val = new BlobKey((String) value);
    } else {
      val = value;
    }
    return val;
  }
View Full Code Here

      return new BlobImpl(new com.google.appengine.api.datastore.Blob(bytes));
   }

   protected byte[] loadBytesInternal(String key, long startIndex, long endIndex)
   {
      BlobKey blobKey = new BlobKey(key);
      return blobstoreService.fetchData(blobKey, startIndex, endIndex);
   }
View Full Code Here

      return blobstoreService.fetchData(blobKey, startIndex, endIndex);
   }

   protected void serveBytesInternal(String key, long start, long end, HttpServletResponse response) throws IOException
   {
      BlobKey blobKey = new BlobKey(key);
      ByteRange range = (end >= 0) ? new ByteRange(start, end) : new ByteRange(start);
      blobstoreService.serve(blobKey, range, response);
   }
View Full Code Here

      }
      finally
      {
         writeChannel.closeFinally();
      }
      BlobKey blobKey = fileService.getBlobKey(file);
      return blobKey.getKeyString();
   }
View Full Code Here

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

        Map<String, BlobKey> blobs = blobstoreService.getUploadedBlobs(req);
        BlobKey blobKey = blobs.get("image");
      
        if (blobKey == null) {

        } else {
View Full Code Here

  private BlobstoreService blobstoreService = BlobstoreServiceFactory
      .getBlobstoreService();

  public void doGet(HttpServletRequest req, HttpServletResponse res)
      throws IOException {
    BlobKey blobKey = new BlobKey(req.getParameter("key"));
    blobstoreService.serve(blobKey, res);
  }
View Full Code Here

              // HACK(ohler): The file service incorrectly uses the current
              // transaction.  Make a dummy transaction as a workaround.
              // Apparently it even needs to be XG.
              CheckedTransaction tx = datastore.beginTransactionXG();
              try {
                BlobKey key = getFileService().getBlobKey(finalizedBlobFile);
                if (key == null) {
                  // I have the impression that this can happen because of HRD's
                  // eventual consistency.  Retry.
                  throw new RetryableFailure(this + ": getBlobKey() returned null");
                }
View Full Code Here

  private BlobKey dump(String fileDescription, byte[] bytes) throws IOException {
    AppEngineFile file = newFile(fileDescription);
    OutputStream out = openForFinalWrite(file);
    out.write(bytes);
    out.close();
    BlobKey blobKey = getBlobKey(file);
    // We verify if what's in the file matches what we wanted to write -- the
    // Files API is still experimental and I've seen it lose data.
    byte[] actualContent = slurp(blobKey);
    if (!Arrays.equals(bytes, actualContent)) {
      throw new IOException("File " + file + " does not contain the bytes we intended to write");
View Full Code Here

            break;
          default:
            throw new RuntimeException("Unexpected type in " + property);
        }
        if (bytes.length > MAX_INLINE_VALUE_BYTES) {
          BlobKey blobKey;
          try {
            blobKey = dump(
                "Oversized value of " + property + " for entity " + entity.getKey(),
                bytes);
          } catch (ApiProxyException e) {
            throw new RuntimeException("Failed to dump " + property + " to file: " + entity, e);
          } catch (IOException e) {
            throw new RuntimeException("Failed to dump " + property + " to file: " + entity, e);
          }
          log.info("Moved " + bytes.length + " bytes from " + property + " to " + blobKey);
          listener.blobCreated(entity.getKey(), property, blobKey);
          entity.removeProperty(property.getPropertyName());
          // We deliberately leave this indexable.  This way, a hypothetical
          // garbage collection algorithm could use the single-property index to
          // find out which blob keys are referenced.  Maybe this makes the
          // listener mechanism redundant...
          entity.setProperty(property.getMovedPropertyName(), blobKey.getKeyString());
        }
      }
    }
  }
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.