将文件写入Blobstore [英] Write files to the Blobstore

查看:91
本文介绍了将文件写入Blobstore的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目标:假设客户端使用Web表单向服务器(Google App Engine)提交字符串或文本文件。我希望服务器修改原始文件并将其提供给客户端。



我认为从GAE提供文件的唯一方法是使用Blobstore,对吧?然后,因为我们不能修改blob,我相信一个解决方案是:


  1. 客户端使用HttpRequest上传文件

  2. 服务器读取上传的文件并将其复制到临时缓冲区(不确定是否有方法执行此操作)

  3. 服务器删除原始blob
  4. 服务器修改临时缓冲区中的数据
  5. 服务器将修改后的缓冲区写入Blobstore
  6. 服务器向客户端提供新的blob / li>

这是否可行?您可以考虑任何其他解决方案吗?



谢谢

p> 我认为从GAE提供文件的唯一方法是使用Blobstore,对吧?

错误。 '文件'只是将数据存储在磁盘上的一种方式;没有任何关于从需要数据来自实际的可写磁盘文件的网络服务器提供服务的问题。您可以简单地通过表单上传,修改并接受用户的数据,而无需触摸磁盘,Blobstore或任何其他永久性存储介质。

如果用户的数据太大而无法放入内存,这只会成为一个问题,在这种情况下,您必须在处理数据时将其存储在某处,例如在Blobstore中。


Objective: Suppose the client submits a string or text file to the server (Google App Engine) using a web form. I want the server to modify the original file and serve it back to the client.

I think the only way to serve files from GAE is using the Blobstore, right? Then, as we cannot modify blobs, I believe a solution would be:

  1. Client uploads a file using HttpRequest
  2. Server reads the uploaded file and copies it to a temp buffer (not sure if is there a method to do this)
  3. Server deletes original blob
  4. Server modifies data in the temp buffer
  5. Server writes the modified buffer to the Blobstore
  6. Server serves the new blob to the client

Would this work? Could you think about any other solution?

Thanks

解决方案

I think the only way to serve files from GAE is using the Blobstore, right?

Wrong. A 'file' is just a way of storing data on disk; there's nothing about serving them from a webserver that requires the data come from an actual, writable disk file. You can simply accept the user's data via a form upload, modify it, and serve it back to them, without it having to ever touch disk, the blobstore, or any other permanent storage medium.

This only becomes a problem if the user's data is too large to fit in memory, in which case you will have to store the data somewhere while you work on it, such as in the blobstore.

这篇关于将文件写入Blobstore的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆