Skip to content
This repository was archived by the owner on May 16, 2019. It is now read-only.

Commit db70e47

Browse files
committed
Change upload_image api call to accept multiple images
1 parent 018b882 commit db70e47

3 files changed

Lines changed: 13 additions & 8 deletions

File tree

api/restapi.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -577,12 +577,14 @@ def respond(success):
577577
@POST('^/api/v1/upload_image')
578578
def upload_image(self, request):
579579
try:
580-
image = request.args["image"][0]
581-
hash_value = digest(image).encode("hex")
582-
with open(DATA_FOLDER + "store/media/" + hash_value, 'w') as outfile:
583-
outfile.write(image)
584-
self.db.HashMap().insert(digest(image), DATA_FOLDER + "store/media/" + hash_value)
585-
request.write(hash_value)
580+
ret = []
581+
for image in request.args["image"]:
582+
hash_value = digest(image).encode("hex")
583+
with open(DATA_FOLDER + "store/media/" + hash_value, 'w') as outfile:
584+
outfile.write(image)
585+
self.db.HashMap().insert(digest(image), DATA_FOLDER + "store/media/" + hash_value)
586+
ret.append(hash_value)
587+
request.write(json.dumps({"success": True, "image_hashes": ret}, indent=4))
586588
request.finish()
587589
return server.NOT_DONE_YET
588590
except Exception, e:

market/contracts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ def add_order_confirmation(self,
381381
with open(file_path, 'w') as outfile:
382382
outfile.write(json.dumps(self.contract, indent=4))
383383

384-
def accept_order_confirmation(self, ws, confirmation_json=False):
384+
def accept_order_confirmation(self, ws, confirmation_json=None):
385385
"""
386386
Validate the order confirmation sent over from the seller and update our node accordingly.
387387
"""

openbazaard.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ def on_bootstrap_complete(resp):
9898
# blockchain
9999
def height_fetched(ec, height):
100100
print "Libbitcoin server online"
101-
timeout.cancel()
101+
try:
102+
timeout.cancel()
103+
except Exception:
104+
pass
102105

103106
def timeout(client):
104107
print "Libbitcoin server offline"

0 commit comments

Comments
 (0)