Package com.google.appengine.api.blobstore

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


 
  public void doPost(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
    RightsManagementController rightsController = RightsManagementController
        .getInstance();
    BlobstoreService blobstoreService = BlobstoreServiceFactory
        .getBlobstoreService();
    Map<String, BlobKey> blobs = blobstoreService.getUploadedBlobs(req);
    BlobKey blobKey = blobs.get("upload");
    if (blobKey == null) {
      redirect(res, blobKey);
      return;
    }
View Full Code Here


    return results;
  }

  private void redirect(HttpServletResponse res, BlobKey blobKey)
      throws IOException {
    BlobstoreService blobstoreService = BlobstoreServiceFactory
        .getBlobstoreService();
    if (blobKey != null)
      blobstoreService.delete(blobKey);
    res.sendRedirect("/upload");
  }
View Full Code Here

      if (null == pr)
        throw new Error("提供的ID尚未註冊, devID = " + devID);
    }

    retJson = new JSONObject();
    BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
    String uploadURL = blobstoreService.createUploadUrl("/image_upload");
    retJson.put("image_upload_url", uploadURL);

    return retJson;
  }
View Full Code Here

 
  /**
   * Extracts blob keys from a request, and returns them as a flat list.
   */
  public static List<String> processRequest(HttpServletRequest req) {
    BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
    Map<String, List<BlobKey>> blobKeyMap = blobstoreService.getUploads(req);
    List<String> blobKeyList = flattenBlobKeyMap(blobKeyMap);
    return blobKeyList;
  }
View Full Code Here

 
  private static Logger log = Logger.getLogger(UploadServlet.class.getName());

  public void doGet(HttpServletRequest req, HttpServletResponse res)
      throws IOException {
    BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
    BlobKey blobKey = new BlobKey(req.getParameter("blob-key"));
    // Writes the file bytes into the response
    blobstoreService.serve(blobKey, res);
    String filename = BlobstoreUtil.getFilename(blobKey);
    log.info("Serving " + blobKey.getKeyString() + " as " + filename);
    res.setHeader("Content-Disposition","attachment;filename=" + filename);
  }
View Full Code Here

      ApplicationTemplate template = (ApplicationTemplate) req
          .getAttribute("template");
      ApplicationConfig config = (ApplicationConfig) req
          .getAttribute("config");
      log.warning("--------do post from test servlet---------");
      BlobstoreService blobService = BlobstoreServiceFactory
          .getBlobstoreService();
      byte b[] = null;
      try {

        Map<String, List<BlobKey>> blobs = blobService.getUploads(req);
        List<BlobKey> blobKeys = blobs.get("template");
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        if (blobKeys != null && blobKeys.size() > 0) {
          for (BlobKey blobKey : blobKeys) {
            b = blobService.fetchData(blobKey, 0, 20);
            if (b.length > 0) {
              FileService fileService = FileServiceFactory
                  .getFileService();
              AppEngineFile file = fileService
                  .getBlobFile(blobKey);
View Full Code Here

  @SuppressWarnings("deprecation")
  @Override
  protected void doPost(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    BlobstoreService blobService = BlobstoreServiceFactory
        .getBlobstoreService();
    ImagesService imageService = ImagesServiceFactory.getImagesService();
    try {
      String alias = req.getParameter("alias");
      News obj = NewsModel.getById(alias);
      if (obj != null) {
        String action = req.getParameter("action");
        String title = req.getParameter("title");
        String content = req.getParameter("content");
        String source = req.getParameter("source");
        String category = req.getParameter("category");
        String tags = req.getParameter("tags");
        if (action != null && action.equals("edit")) {
          obj.setTitle(title);
          obj.setAlias(StringHelper.replaceVietnamese(title));
          obj.setContent(content);
          obj.setSource(source);

          /*
           * process thumb image
           */
          try {
            Map<String, List<BlobKey>> blobs = blobService
                .getUploads(req);
            List<BlobKey> blobKeys = blobs.get("img");
            if (blobKeys != null && blobKeys.size() > 0) {
              for (BlobKey blobKey : blobKeys) {
                byte[] arr = blobService.fetchData(blobKey, 0,
                    20);
                if (arr.length > 0) {
                  obj.setThumb(imageService
                      .getServingUrl(blobKey));
                }
View Full Code Here

  @SuppressWarnings("deprecation")
  @Override
  protected void doPost(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    BlobstoreService blobService = BlobstoreServiceFactory
        .getBlobstoreService();
    ImagesService imageService = ImagesServiceFactory.getImagesService();
    try {
      String action = req.getParameter("action");
      String title = req.getParameter("title");
      String content = req.getParameter("content");
      String source = req.getParameter("source");
      String category = req.getParameter("category");
      String tags = req.getParameter("tags");
      News obj = new News();
      if (action != null && action.equals("add")) {
        obj.setTitle(title);
        obj.setAlias(StringHelper.replaceVietnamese(title));
        News checkObj = NewsModel.getById(obj.getAlias());
        if (checkObj != null) {
          obj.setAlias(obj.getAlias() + "-"
              + IdUniqueHelper.getId().toLowerCase());
        }
        obj.setContent(content);
        obj.setSource(source);

        /*
         * process thumb image
         */
        try {
          Map<String, List<BlobKey>> blobs = blobService
              .getUploads(req);
          List<BlobKey> blobKeys = blobs.get("img");
          if (blobKeys != null && blobKeys.size() > 0) {
            for (BlobKey blobKey : blobKeys) {
              byte[] arr = blobService.fetchData(blobKey, 0, 20);
              if (arr.length > 0) {
                obj.setThumb(imageService
                    .getServingUrl(blobKey));
              }
            }
View Full Code Here

   */
  @Override
  public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    GcsFilename fileName = getFileName(req);
    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());
    }
  }
View Full Code Here

  //"Override the doPost method to store the Blob's meta-data "
  public void doPost(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
    System.out.println("entered doPost of HUDXML3UploadService");
      BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
      //Map<String, BlobKey> blobs = blobstoreService.getUploadedBlobs(req);
    Map<String, List<BlobKey>> blobs = blobstoreService.getUploads(req);
    for (Map.Entry<String,  List<BlobKey>> entry : blobs.entrySet())
    {
        System.out.println(entry.getKey() + "/" + entry.getValue());
    }
View Full Code Here

TOP

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

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.