Skip to content

Commit bd18e3a

Browse files
committed
Catch exceptions thrown by images.get_serving_url.
1 parent e1e854b commit bd18e3a

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

gae/main.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# jQuery File Upload Plugin GAE Example 1.1.1
3+
# jQuery File Upload Plugin GAE Example 1.1.2
44
# https://github.com/blueimp/jQuery-File-Upload
55
#
66
# Copyright 2010, Sebastian Tschan
@@ -79,17 +79,20 @@ def handle_upload(self):
7979
self.write_blob(fieldStorage.value, result)
8080
)
8181
blob_keys.append(blob_key)
82+
result['delete_type'] = 'DELETE'
83+
result['delete_url'] = self.request.host_url +\
84+
'/?key=' + urllib.quote(blob_key, '')
8285
if (IMAGE_TYPES.match(result['type'])):
83-
result['url'] = images.get_serving_url(blob_key)
84-
result['thumbnail_url'] = result['url'] +\
85-
THUMBNAIL_MODIFICATOR
86-
else:
86+
try:
87+
result['url'] = images.get_serving_url(blob_key)
88+
result['thumbnail_url'] = result['url'] +\
89+
THUMBNAIL_MODIFICATOR
90+
except: # Could not get an image serving url
91+
pass
92+
if not 'url' in result:
8793
result['url'] = self.request.host_url +\
8894
'/' + blob_key + '/' + urllib.quote(
8995
result['name'].encode('utf-8'), '')
90-
result['delete_type'] = 'DELETE'
91-
result['delete_url'] = self.request.host_url +\
92-
'/?key=' + urllib.quote(blob_key, '')
9396
results.append(result)
9497
deferred.defer(
9598
cleanup,

0 commit comments

Comments
 (0)