1

I'm using the Google App Engine Blobstore service to store HTML files. These files correspond to webpages I'm trying to allow my users to edit and update.

If I have HTML files in the blobstore, what would be the easiest way to fetch the HTML code from the files stored and display the code in a TextArea etc.? Then how would I go about updating that file in the blobstore?

I know there is the fetchData method which returns a byte array, so how could I display the plain text HTML code from an HTML file in the blobstore?

4

2 回答 2

1

我还存储 HTML 和 TXT 文件,但我将这些文件存储在数据存储的 blob 属性中。

args['text_area'] = db.Blob(db_block.content).decode('utf-8')

我使用 codemirror 来编辑文件/texterea。工作出色。更新:

db_block.content = db.Blob(args['text_area'].encode('utf-8'))
db_block.put()
于 2012-02-27T01:34:52.467 回答
0

弄清楚了。我使用通过 GET 参数传递的 blobKey 抓取字节数组,然后使用:

fetchData(blobKey, 0, BlobstoreService.MAX_BLOB_SIZE-1);

要将字节数组打印为可读的 HTML 代码:

<textarea id="content" name="content" rows="15" cols="85"> 
<%for(int i=0; i<blobData.length; i++){%>
<%=(char)blobData[i]%><%}%> 
</textarea></td>
于 2012-02-27T00:22:28.540 回答