@POST('^/api/v1/upload_image')
    @authenticated
    def upload_image(self, request):
        try:
            ret = []
            if "image" in request.args:
                for image in request.args["image"]:
                    img = image.decode('base64')
                    hash_value = digest(img).encode("hex")
                    with open(os.path.join(DATA_FOLDER, "store", "media", hash_value), 'wb') as outfile:
                        outfile.write(img)
                    self.db.filemap.insert(hash_value, os.path.join("store", "media", hash_value))
                    ret.append(hash_value)
            elif "avatar" in request.args:
                avi = request.args["avatar"][0].decode("base64")
                hash_value = digest(avi).encode("hex")
                with open(os.path.join(DATA_FOLDER, "store", "avatar"), 'wb') as outfile:
                    outfile.write(avi)
                self.db.filemap.insert(hash_value, os.path.join("store", "avatar"))
                ret.append(hash_value)
            elif request.args in "header":
                hdr = request.args["header"][0].decode("base64")
                hash_value = digest(hdr).encode("hex")
                with open(os.path.join(DATA_FOLDER, "store", "header"), 'wb') as outfile:
                    outfile.write(hdr)
                self.db.filemap.insert(hash_value, os.path.join("store", "header"))
                ret.append(hash_value)
            request.write(json.dumps({"success": True, "image_hashes": ret}, indent=4))
            request.finish()
            return server.NOT_DONE_YET
        except Exception, e:
            request.write(json.dumps({"success": False, "reason": e.message}, indent=4))
            request.finish()
            return server.NOT_DONE_YET
dataset/ETHPy150Open OpenBazaar/OpenBazaar-Server/api/restapi.py/OpenBazaarAPI.upload_image/swapped operands of `in`