I'm trying to write an image to the blob store. I've tried fetch_response = urlfetch.fetch(image_url, deadline=10)
which timed out and now I'm trying rpc with the same result. Can someone tell me what's wrong with the following code? Thanks for your help:
media_items = ['logo.png']
content_type = 'image/png'
for media_item in media_items:
image_url = 'http://localhost:8080/image/' + media_item
#fetch_response = urlfetch.fetch(image_url, deadline=10)
rpc = urlfetch.create_rpc(deadline=20)
urlfetch.make_fetch_call(rpc, image_url)
try:
file_data = rpc.get_result()
file_name = files.blobstore.create(mime_type=content_type)
with files.open(file_name, 'a') as f:
f.write(file_data)
files.finalize(file_name)
blob_key = files.blobstore.get_blob_key(file_name)
create_media_item(blob_key)
except urlfetch.DownloadError:
logging.error('DownloadError')
This is running on my machine and if I look at the picture in the browser using this URL it displays. My logging.error() is printed.