1
votes

I am looking for some assistance on how to implement dynamic html content using blostore api with Google Cloud Storage. Currently our site rely's on CloudStorage where all our static content (html5) is stored, which we call and serve using the blobstore api. That way the content owners can independently upload html/image/swf content on their own to CloudStorage.

Currently content is all static, and we now want to pass in data from our CloudSQL such as "seen the page" which we will pull from our CloudSQL DB as well as other data for example from the AppEngine userservice. The code below shows how we do it now with the blobstore api:

gs_filename = '/gs/%s/%s' % (settings.BUCKET, filename)
bkey = blobstore.create_gs_key(gs_filename)
return blobstore_dh.send_blob(bkey, content_type=ct)

My question is, how can I pass in data from the CloudSQL DB to the HTML that currently is hosted on CloudStorage still using the blobstore api? Content is all static, and it needs to become more dynamic using django for example as the framework.

I'm not grasping how this is feasible currently using the blobstore api. Any ideas on how to implement this? Thanks for your time.

1
Question is really too broad. Pick a framework first at least. - Zig Mandel
What you want is not possible at the blobstore api level. You need to replace your templates after you fetch from blobstore. One major problem you will have is that those that can upload html will also need to code the backend that populates their templates. But could work if all you want is to always append a page counter at the bottom of the html - Zig Mandel
Another option is to receive such parameters by url so that your servlet just appends the parameters to the blobstore url. Then the html's javascript does the work to put the parameters in the right places. - Zig Mandel
Thanks for your response. I was going to go with Django, but wasn't sure how to make it work with the blobstore api. I'll look into your javascript option. Thanks again. - user2690151

1 Answers

1
votes

You need to use the BlobReader class to read the data from the blob, transform the data however you want and then send the transformed data yourself.