简体   繁体   中英

trying to retrieve file from blobstore and send it as mail attachment using google app engine

I am trying to design an application that would require me to retrieve data stored in blobstore and send it as attachment. Does google app engine allow this? From the documentation, i could not find a way to retrieve data from blobstore for processing within the app.. can someone please tell me how to accomplish this? Code examples and/or pointers to related online resources would be really helpful.

As of now, it seems this isn't possible. You can only cause the the file to be sent to the client .

It's possible you could do what you need using a Datastore Blob ?

It's worth also noting that the Blobstore is "experimental" and may change. It's possible additional functionality may be added that would allow what you'r trying to do.

您现在可以使用BlobReader从blobstore读取数据, BlobReader提供了一个简单的,类似文件的界面。

You can use BlobstoreInputStream to do almost the same thing as BlobReader do.

https://developers.google.com/appengine/docs/java/javadoc/com/google/appengine/api/blobstore/BlobstoreInputStream

BlobstoreInputStream provides an InputStream view of a blob in Blobstore. It is thread compatible but not thread safe: there is no static state, but any multithreaded use must be externally synchronized.

This can be accomplished in two steps using the code from the Complete Sample App. http://code.google.com/appengine/docs/java/blobstore/overview.html#Complete_Sample_App

1) Write a servlet that takes a blobkey and returns the contents of the blob.

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

2) Within your application, use the URLFetchService.fetch(java.net.URL url) with the proper blobkey to retrieve the blob (as a stream) and attach it to the email.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM