java - 给定 BlobstoreService 提供的 HttpServletResponse,如何获取提供的 blob?

标签 java android google-app-engine servlets blobstore

这是我的 Serve.java,这是我的 Serve servlet

public class Serve extends HttpServlet {
private BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();

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

    }
}

当我托管服务器并通过浏览器访问服务servlet时,我看到我的blob(图片)。因此,我假设图片文件格式的 blob 存储在 HttpServletResponse 中。

如何访问此blob/文件?我实际上需要使用 HttpResponse 来自 Android 应用程序的文件,但我会自己解决这个问题。

最佳答案

您可以创建 BlobstoreInputStream 以编程方式从 BlobStore 读取 blob。
如果您需要在 Android 应用程序中使用该文件,则应按照您已有的方式提供该文件,只需在应用程序中读取响应即可。

关于java - 给定 BlobstoreService 提供的 HttpServletResponse,如何获取提供的 blob?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15425367/

相关文章:

java - 方法拦截器未在测试中调用

java - 为什么在启动 Spring Boot 应用程序时会出现 Gson 构建器错误?

android - 改造 : RestAdapter. Builder() 与 Retrofit.Builder()

android - Proguard 中的自定义混淆类名

windows - Google Cloud SDK 安装失败 '.exe;.bat;.com' 不是可识别的命令

database - 与谷歌应用程序引擎兼容的简单网络应用程序

google-app-engine - Google App Engine 中任务队列的时间限制

java - Eclipse Java Debug模式 : how to get actual type of value?

java - Spring Boot - Injecting Repository into Controller throws 考虑在您的配置中定义一个类型为 'Type' 的 bean

android - 为 Assets 和资源文件夹指定其他路径-Android Studio