Hi,

http://demofileuploadgae.appspot.com/ - My simple demo of the use of
the Blobstore and GWT. I'm pretty impressed at how well it works!

http://code.google.com/p/gwt-examples/source/browse/trunk/DemoUpload/
- GWT GAE project source for the demo.

I figured out how to use the low level api to query the __BlobInfo_
entities so I could return a list. More custom filters could be added
to drill down your list of blobs that you have in the store. Also,
with GWT you have to use an rpc call to get init a url for file
upload, so the servlet knows what to do with it.

Brandon Donnelson
http://gwt-examples.googlecode.com


Worth noting:
http://code.google.com/p/gwt-examples/source/browse/trunk/DemoUpload/src/org/gonevertical/upload/server/BlobInfoJdo.java
- source for below
public BlobData[] getBlobs(BlobDataFilter filter) {

    Entity[] entities = null;
    try {
      DatastoreService datastore =
DatastoreServiceFactory.getDatastoreService();
      PreparedQuery pq = datastore.prepare(new Query("__BlobInfo__"));
      List<Entity> entList =
pq.asList(FetchOptions.Builder.withLimit((int)
filter.getRangeFinish()).offset((int) filter.getRangeStart()));

      entities = new Entity[entList.size()];
      entList.toArray(entities);

    } finally {
      pm.close();
    }

    BlobData[] blobData = convert(entities);

    return blobData;
  }

  private BlobData[] convert(Entity[] es) {
    if (es == null || es.length == 0) {
      return null;
    }

    BlobData[] b = new BlobData[es.length];
    for (int i=0; i < es.length; i++) {

      Map<String, Object> p = es[i].getProperties();

      long id = es[i].getKey().getId();
      Key key = es[i].getKey();
      String ct = (String) es[i].getProperty("content_type");
      String fn = (String) es[i].getProperty("filename");
      Long size = (Long) es[i].getProperty("size");
      Date creation = (Date) es[i].getProperty("creation");

      b[i] = new BlobData();
      b[i].setKey(key.getName());
      b[i].setContentType(ct);
      b[i].setFilename(fn);
      b[i].setSize(size);
      b[i].setCreation(creation);

    }

    return b;
  }

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to