Package com.google.appengine.api.blobstore

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


   
    FileDownloadPath path = AutoBeanUtil.decode(FileDownloadPath.class, encodedPath);
   
    switch(path.getType()) {
    case BLOBSTORE_BLOB:
      BlobstoreService blobstore = BlobstoreServiceFactory.getBlobstoreService();
      BlobKey blobKey = new BlobKey(path.getKeyStr());
      blobstore.serve(blobKey, resp);
      break;
    case DATASTORE_BLOB:
    case DATASTORE_TEXT:
      DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
      Key key = KeyFactory.stringToKey(path.getKeyStr());
View Full Code Here


    return result;
  }

  @Override
  public void delete(Collection<String> blobKeyStrs) throws YaacException {
    BlobstoreService blobstore = BlobstoreServiceFactory.getBlobstoreService();
   
    BlobKey [] keys = new BlobKey[blobKeyStrs.size()];
   
    int i = 0;
    for (String blobKeyStr : blobKeyStrs) {
      keys[i++] = new BlobKey(blobKeyStr);
    }
   
    blobstore.delete(keys);
  }
View Full Code Here

      throws FileNotFoundException, IOException {
    Step step = MiniProfiler.step("API.getZipFile");

    try {

      final BlobstoreService blobstoreService = BlobstoreServiceFactory
          .getBlobstoreService();

      BlobInfo info = new BlobInfoFactory().loadBlobInfo(csvBlobKey);

      byte[] bytes = blobstoreService.fetchData(csvBlobKey, 0,
          info.getSize());

      final ZipInputStream zipIn = new ZipInputStream(
          new ByteArrayInputStream(bytes));
View Full Code Here

      } catch (IOException ioe) {
        ioe.printStackTrace();
      } finally {
        // delete the zip
        if (zipBlobKey != null) {
          BlobstoreService blobstoreService = BlobstoreServiceFactory
              .getBlobstoreService();
          blobstoreService.delete(zipBlobKey);
        }
      }
    } finally {
      step.close();
    }
View Full Code Here

    // multipart/form-data
    final String contentType = request.getContentType();

    if (contentType != null && contentType.contains("multipart/form-data")) {

      final BlobstoreService blobstoreService = BlobstoreServiceFactory
          .getBlobstoreService();

      final Map<String, List<BlobKey>> blobKeysValues = blobstoreService
          .getUploads(request);
      for (final Entry<String, List<BlobKey>> blobKeyValues : blobKeysValues
          .entrySet()) {
        for (final BlobKey blobKey : blobKeyValues.getValue()) {
          final BlobInfo blobInfo = new BlobInfoFactory()
              .loadBlobInfo(blobKey);
          final long size = blobInfo.getSize();
          if (size > 0) {
            // process blob
            parameters.put(blobKeyValues.getKey(), blobKey);
          } else {
            blobstoreService.delete(blobKey);
          }
        }
      }
    }
View Full Code Here

            return doPost();
        }
    }

    Navigation doPost() throws IOException {
        BlobstoreService blobstoreService =
            BlobstoreServiceFactory.getBlobstoreService();
        Map<String, List<BlobKey>> blobs = blobstoreService.getUploads(request);
        Entry<String, List<BlobKey>> next = blobs.entrySet().iterator().next();
        return redirect(PATH + "?key=" + next.getValue().get(0).getKeyString());
    }
View Full Code Here

        String blobKeyString = asString("download");
        if (StringUtil.isEmpty(blobKeyString)) {
            response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
            return null;
        }
        BlobstoreService blobstoreService =
            BlobstoreServiceFactory.getBlobstoreService();
        BlobKey blobKey = new BlobKey(blobKeyString);
        BlobInfo blobInfo = new BlobInfoFactory().loadBlobInfo(blobKey);
        response.setContentType(blobInfo.getContentType());
        response.setContentLength((int) blobInfo.getSize());
        response.setHeader(
            "Content-disposition",
            "attachment;" + blobInfo.getFilename());
        byte[] data =
            blobstoreService.fetchData(blobKey, 0, blobInfo.getSize());
        response.getOutputStream().write(data);
        response.flushBuffer();
        return null;
    }
View Full Code Here

public class ProcessUploadUrl extends HttpServlet {
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws IOException {
    String returnUrl = request.getParameter("returnUrl");
    if (returnUrl != null && returnUrl.length() > 0) {
      BlobstoreService blobstoreService = BlobstoreServiceFactory
          .getBlobstoreService();
      String uploadUrl = blobstoreService.createUploadUrl(returnUrl);
      response.setContentType("text/plain");
      response.getWriter().print(uploadUrl);
    }
  }
View Full Code Here

public class UserImageServiceImpl extends RemoteServiceServlet implements
    UserImageService {

  @Override
  public String getBlobstoreUploadUrl() {
    BlobstoreService blobstoreService = BlobstoreServiceFactory
        .getBlobstoreService();
    return blobstoreService.createUploadUrl("/upload");
  }
View Full Code Here

@SuppressWarnings("serial")
public class UploadBlobServlet extends HttpServlet {
  public void doPost(HttpServletRequest req, HttpServletResponse resp)
      throws IOException {

    BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
    Map<String, BlobKey> blobs = blobstoreService.getUploadedBlobs(req);
    BlobKey blobKey = blobs.get("data");

    if (blobKey == null) {
      resp.sendRedirect("/");
    } else {
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.