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 f开发者_运维知识库iles 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?
I'am also storing HTML and TXT files, but I store these files in a blobproperty of the datastore.
args['text_area'] = db.Blob(db_block.content).decode('utf-8')
I use codemirror to edit the files / the texterea. Works excellent. Updating :
db_block.content = db.Blob(args['text_area'].encode('utf-8'))
db_block.put()
figured it out. I grabbed the byte array using the blobKey passed through a GET paramater, and then used:
fetchData(blobKey, 0, BlobstoreService.MAX_BLOB_SIZE-1);
To print the byte array as readable HTML code:
<textarea id="content" name="content" rows="15" cols="85">
<%for(int i=0; i<blobData.length; i++){%>
<%=(char)blobData[i]%><%}%>
</textarea></td>
精彩评论