prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Image uploader does not recognise uploaded file
  <!-- What problem are we solving? What does the experience look like today? What are the symptoms? -->
  As of today (8-09-2021) the image uploader does not recognise that an image has been selected and uploaded. Instead, it displays "Please provide an image URL" after hitting submit.
  
  ### Evidence / Screenshot (if possible)
  
  ### Relevant url?
  <!-- `https://openlibrary.org/...` -->
  
  ### Steps to Reproduce
  <!-- What steps caused you to find the bug? -->
  1. Go to ...any edition
  2. Do ...upload an image as a cover and submit.
  
  <!-- What actually happened after these steps? What did you expect to happen? -->
  * Actual: "Please provide an image URL"
  * Expected: Image should be added as cover.
  
  ### Details
  
  - **Logged in (Y/N)?** y
  - **Browser type/version?** Chrome Version 92.0.4515.159 (Official Build) (x86_64)
  - **Operating system?** MacOS
  - **Environment (prod/dev/local)?** prod
  <!-- If not sure, put prod -->
  
  ### Proposal & Constraints
  <!-- What is the proposed solution / implementation? Is there a precedent of this approach succeeding elsewhere? -->
  
  ### Related files
  <!-- Files related to this issue; this is super useful for new contributors who might want to help! If you're not sure, leave this blank; a maintainer will add them. -->
  
  ### Stakeholders
  <!-- @ tag stakeholders of this bug -->
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `openlibrary/plugins/upstream/covers.py`
  Content:
  ```
  1 """Handle book cover/author photo upload.
  2 """
  3 from logging import getLogger
  4 
  5 import requests
  6 import six
  7 import web
  8 from six import BytesIO
  9 
  10 from infogami.utils import delegate
  11 from infogami.utils.view import safeint
  12 from openlibrary import accounts
  13 from openlibrary.plugins.upstream.models import Image
  14 from openlibrary.plugins.upstream.utils import get_coverstore_url, render_template
  15 
  16 logger = getLogger("openlibrary.plugins.upstream.covers")
  17 def setup():
  18     pass
  19 
  20 class add_cover(delegate.page):
  21     path = "(/books/OL\d+M)/add-cover"
  22     cover_category = "b"
  23 
  24     def GET(self, key):
  25         book = web.ctx.site.get(key)
  26         return render_template('covers/add', book)
  27 
  28     def POST(self, key):
  29         book = web.ctx.site.get(key)
  30         if not book:
  31             raise web.notfound("")
  32 
  33         i = web.input(file={}, url="")
  34 
  35         # remove references to field storage objects
  36         web.ctx.pop("_fieldstorage", None)
  37 
  38         data = self.upload(key, i)
  39         coverid = data.get('id')
  40 
  41         if coverid:
  42             self.save(book, coverid, url=i.url)
  43             cover = Image(web.ctx.site, "b", coverid)
  44             return render_template("covers/saved", cover)
  45         else:
  46             return render_template("covers/add", book, {'url': i.url}, data)
  47 
  48     def upload(self, key, i):
  49         """Uploads a cover to coverstore and returns the response."""
  50         olid = key.split("/")[-1]
  51 
  52         if i.file is not None and hasattr(i.file, 'value'):
  53             data = i.file.value
  54         else:
  55             data = None
  56 
  57         if i.url and i.url.strip() == "http://":
  58             i.url = ""
  59 
  60         user = accounts.get_current_user()
  61         params = {
  62             "author": user and user.key,
  63             "source_url": i.url,
  64             "olid": olid,
  65             "ip": web.ctx.ip
  66         }
  67 
  68         upload_url = '%s/%s/upload2' % (
  69             get_coverstore_url(), self.cover_category)
  70 
  71         if upload_url.startswith("//"):
  72             upload_url = "http:" + upload_url
  73 
  74         try:
  75             files = {'data': BytesIO(data)}
  76             response = requests.post(upload_url, data=params, files=files)
  77             return web.storage(response.json())
  78         except requests.HTTPError as e:
  79             logger.exception("Covers upload failed")
  80             return web.storage({'error': str(e)})
  81 
  82     def save(self, book, coverid, url=None):
  83         book.covers = [coverid] + [cover.id for cover in book.get_covers()]
  84         book._save("Added new cover", action="add-cover", data={"url": url})
  85 
  86 class add_work_cover(add_cover):
  87     path = "(/works/OL\d+W)/add-cover"
  88     cover_category = "w"
  89 
  90     def upload(self, key, i):
  91         if "coverid" in i and safeint(i.coverid):
  92             return web.storage(id=int(i.coverid))
  93         else:
  94             return add_cover.upload(self, key, i)
  95 
  96 class add_photo(add_cover):
  97     path = "(/authors/OL\d+A)/add-photo"
  98     cover_category = "a"
  99 
  100     def save(self, author, photoid, url=None):
  101         author.photos = [photoid] + [photo.id for photo in author.get_photos()]
  102         author._save("Added new photo", action="add-photo", data={"url": url})
  103 
  104 class manage_covers(delegate.page):
  105     path = "(/books/OL\d+M)/manage-covers"
  106     def GET(self, key):
  107         book = web.ctx.site.get(key)
  108         if not book:
  109             raise web.notfound()
  110         return render_template("covers/manage", key, self.get_images(book))
  111 
  112     def get_images(self, book):
  113         return book.get_covers()
  114 
  115     def get_image(self, book):
  116         return book.get_cover()
  117 
  118     def save_images(self, book, covers):
  119         book.covers = covers
  120         book._save('Update covers')
  121 
  122     def POST(self, key):
  123         book = web.ctx.site.get(key)
  124         if not book:
  125             raise web.notfound()
  126 
  127         images = web.input(image=[]).image
  128         if '-' in images:
  129             images = [int(id) for id in images[:images.index('-')]]
  130             self.save_images(book, images)
  131             return render_template("covers/saved", self.get_image(book), showinfo=False)
  132         else:
  133             # ERROR
  134             pass
  135 
  136 class manage_work_covers(manage_covers):
  137     path = "(/works/OL\d+W)/manage-covers"
  138 
  139 
  140 class manage_photos(manage_covers):
  141     path = "(/authors/OL\d+A)/manage-photos"
  142 
  143     def get_images(self, author):
  144         return author.get_photos()
  145 
  146     def get_image(self, author):
  147         return author.get_photo()
  148 
  149     def save_images(self, author, photos):
  150         author.photos = photos
  151         author._save('Update photos')
  152
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/openlibrary/plugins/upstream/covers.py b/openlibrary/plugins/upstream/covers.py
  --- a/openlibrary/plugins/upstream/covers.py
  +++ b/openlibrary/plugins/upstream/covers.py
  @@ -54,7 +54,7 @@
           else:
               data = None
   
  -        if i.url and i.url.strip() == "http://":
  +        if i.url and i.url.strip() == "https://":
               i.url = ""
   
           user = accounts.get_current_user()
  
verification_info: {"golden_diff": "diff --git a/openlibrary/plugins/upstream/covers.py b/openlibrary/plugins/upstream/covers.py\n--- a/openlibrary/plugins/upstream/covers.py\n+++ b/openlibrary/plugins/upstream/covers.py\n@@ -54,7 +54,7 @@\n         else:\n             data = None\n \n-        if i.url and i.url.strip() == \"http://\":\n+        if i.url and i.url.strip() == \"https://\":\n             i.url = \"\"\n \n         user = accounts.get_current_user()\n", "issue": "Image uploader does not recognise uploaded file\n<!-- What problem are we solving? What does the experience look like today? What are the symptoms? -->\r\nAs of today (8-09-2021) the image uploader does not recognise that an image has been selected and uploaded. Instead, it displays \"Please provide an image URL\" after hitting submit.\r\n\r\n### Evidence / Screenshot (if possible)\r\n\r\n### Relevant url?\r\n<!-- `https://openlibrary.org/...` -->\r\n\r\n### Steps to Reproduce\r\n<!-- What steps caused you to find the bug? -->\r\n1. Go to ...any edition\r\n2. Do ...upload an image as a cover and submit.\r\n\r\n<!-- What actually happened after these steps? What did you expect to happen? -->\r\n* Actual: \"Please provide an image URL\"\r\n* Expected: Image should be added as cover.\r\n\r\n### Details\r\n\r\n- **Logged in (Y/N)?** y\r\n- **Browser type/version?** Chrome Version 92.0.4515.159 (Official Build) (x86_64)\r\n- **Operating system?** MacOS\r\n- **Environment (prod/dev/local)?** prod\r\n<!-- If not sure, put prod -->\r\n\r\n### Proposal & Constraints\r\n<!-- What is the proposed solution / implementation? Is there a precedent of this approach succeeding elsewhere? -->\r\n\r\n### Related files\r\n<!-- Files related to this issue; this is super useful for new contributors who might want to help! If you're not sure, leave this blank; a maintainer will add them. -->\r\n\r\n### Stakeholders\r\n<!-- @ tag stakeholders of this bug -->\r\n\n", "before_files": [{"content": "\"\"\"Handle book cover/author photo upload.\n\"\"\"\nfrom logging import getLogger\n\nimport requests\nimport six\nimport web\nfrom six import BytesIO\n\nfrom infogami.utils import delegate\nfrom infogami.utils.view import safeint\nfrom openlibrary import accounts\nfrom openlibrary.plugins.upstream.models import Image\nfrom openlibrary.plugins.upstream.utils import get_coverstore_url, render_template\n\nlogger = getLogger(\"openlibrary.plugins.upstream.covers\")\ndef setup():\n    pass\n\nclass add_cover(delegate.page):\n    path = \"(/books/OL\\d+M)/add-cover\"\n    cover_category = \"b\"\n\n    def GET(self, key):\n        book = web.ctx.site.get(key)\n        return render_template('covers/add', book)\n\n    def POST(self, key):\n        book = web.ctx.site.get(key)\n        if not book:\n            raise web.notfound(\"\")\n\n        i = web.input(file={}, url=\"\")\n\n        # remove references to field storage objects\n        web.ctx.pop(\"_fieldstorage\", None)\n\n        data = self.upload(key, i)\n        coverid = data.get('id')\n\n        if coverid:\n            self.save(book, coverid, url=i.url)\n            cover = Image(web.ctx.site, \"b\", coverid)\n            return render_template(\"covers/saved\", cover)\n        else:\n            return render_template(\"covers/add\", book, {'url': i.url}, data)\n\n    def upload(self, key, i):\n        \"\"\"Uploads a cover to coverstore and returns the response.\"\"\"\n        olid = key.split(\"/\")[-1]\n\n        if i.file is not None and hasattr(i.file, 'value'):\n            data = i.file.value\n        else:\n            data = None\n\n        if i.url and i.url.strip() == \"http://\":\n            i.url = \"\"\n\n        user = accounts.get_current_user()\n        params = {\n            \"author\": user and user.key,\n            \"source_url\": i.url,\n            \"olid\": olid,\n            \"ip\": web.ctx.ip\n        }\n\n        upload_url = '%s/%s/upload2' % (\n            get_coverstore_url(), self.cover_category)\n\n        if upload_url.startswith(\"//\"):\n            upload_url = \"http:\" + upload_url\n\n        try:\n            files = {'data': BytesIO(data)}\n            response = requests.post(upload_url, data=params, files=files)\n            return web.storage(response.json())\n        except requests.HTTPError as e:\n            logger.exception(\"Covers upload failed\")\n            return web.storage({'error': str(e)})\n\n    def save(self, book, coverid, url=None):\n        book.covers = [coverid] + [cover.id for cover in book.get_covers()]\n        book._save(\"Added new cover\", action=\"add-cover\", data={\"url\": url})\n\nclass add_work_cover(add_cover):\n    path = \"(/works/OL\\d+W)/add-cover\"\n    cover_category = \"w\"\n\n    def upload(self, key, i):\n        if \"coverid\" in i and safeint(i.coverid):\n            return web.storage(id=int(i.coverid))\n        else:\n            return add_cover.upload(self, key, i)\n\nclass add_photo(add_cover):\n    path = \"(/authors/OL\\d+A)/add-photo\"\n    cover_category = \"a\"\n\n    def save(self, author, photoid, url=None):\n        author.photos = [photoid] + [photo.id for photo in author.get_photos()]\n        author._save(\"Added new photo\", action=\"add-photo\", data={\"url\": url})\n\nclass manage_covers(delegate.page):\n    path = \"(/books/OL\\d+M)/manage-covers\"\n    def GET(self, key):\n        book = web.ctx.site.get(key)\n        if not book:\n            raise web.notfound()\n        return render_template(\"covers/manage\", key, self.get_images(book))\n\n    def get_images(self, book):\n        return book.get_covers()\n\n    def get_image(self, book):\n        return book.get_cover()\n\n    def save_images(self, book, covers):\n        book.covers = covers\n        book._save('Update covers')\n\n    def POST(self, key):\n        book = web.ctx.site.get(key)\n        if not book:\n            raise web.notfound()\n\n        images = web.input(image=[]).image\n        if '-' in images:\n            images = [int(id) for id in images[:images.index('-')]]\n            self.save_images(book, images)\n            return render_template(\"covers/saved\", self.get_image(book), showinfo=False)\n        else:\n            # ERROR\n            pass\n\nclass manage_work_covers(manage_covers):\n    path = \"(/works/OL\\d+W)/manage-covers\"\n\n\nclass manage_photos(manage_covers):\n    path = \"(/authors/OL\\d+A)/manage-photos\"\n\n    def get_images(self, author):\n        return author.get_photos()\n\n    def get_image(self, author):\n        return author.get_photo()\n\n    def save_images(self, author, photos):\n        author.photos = photos\n        author._save('Update photos')\n", "path": "openlibrary/plugins/upstream/covers.py"}], "after_files": [{"content": "\"\"\"Handle book cover/author photo upload.\n\"\"\"\nfrom logging import getLogger\n\nimport requests\nimport six\nimport web\nfrom six import BytesIO\n\nfrom infogami.utils import delegate\nfrom infogami.utils.view import safeint\nfrom openlibrary import accounts\nfrom openlibrary.plugins.upstream.models import Image\nfrom openlibrary.plugins.upstream.utils import get_coverstore_url, render_template\n\nlogger = getLogger(\"openlibrary.plugins.upstream.covers\")\ndef setup():\n    pass\n\nclass add_cover(delegate.page):\n    path = \"(/books/OL\\d+M)/add-cover\"\n    cover_category = \"b\"\n\n    def GET(self, key):\n        book = web.ctx.site.get(key)\n        return render_template('covers/add', book)\n\n    def POST(self, key):\n        book = web.ctx.site.get(key)\n        if not book:\n            raise web.notfound(\"\")\n\n        i = web.input(file={}, url=\"\")\n\n        # remove references to field storage objects\n        web.ctx.pop(\"_fieldstorage\", None)\n\n        data = self.upload(key, i)\n        coverid = data.get('id')\n\n        if coverid:\n            self.save(book, coverid, url=i.url)\n            cover = Image(web.ctx.site, \"b\", coverid)\n            return render_template(\"covers/saved\", cover)\n        else:\n            return render_template(\"covers/add\", book, {'url': i.url}, data)\n\n    def upload(self, key, i):\n        \"\"\"Uploads a cover to coverstore and returns the response.\"\"\"\n        olid = key.split(\"/\")[-1]\n\n        if i.file is not None and hasattr(i.file, 'value'):\n            data = i.file.value\n        else:\n            data = None\n\n        if i.url and i.url.strip() == \"https://\":\n            i.url = \"\"\n\n        user = accounts.get_current_user()\n        params = {\n            \"author\": user and user.key,\n            \"source_url\": i.url,\n            \"olid\": olid,\n            \"ip\": web.ctx.ip\n        }\n\n        upload_url = '%s/%s/upload2' % (\n            get_coverstore_url(), self.cover_category)\n\n        if upload_url.startswith(\"//\"):\n            upload_url = \"http:\" + upload_url\n\n        try:\n            files = {'data': BytesIO(data)}\n            response = requests.post(upload_url, data=params, files=files)\n            return web.storage(response.json())\n        except requests.HTTPError as e:\n            logger.exception(\"Covers upload failed\")\n            return web.storage({'error': str(e)})\n\n    def save(self, book, coverid, url=None):\n        book.covers = [coverid] + [cover.id for cover in book.get_covers()]\n        book._save(\"Added new cover\", action=\"add-cover\", data={\"url\": url})\n\nclass add_work_cover(add_cover):\n    path = \"(/works/OL\\d+W)/add-cover\"\n    cover_category = \"w\"\n\n    def upload(self, key, i):\n        if \"coverid\" in i and safeint(i.coverid):\n            return web.storage(id=int(i.coverid))\n        else:\n            return add_cover.upload(self, key, i)\n\nclass add_photo(add_cover):\n    path = \"(/authors/OL\\d+A)/add-photo\"\n    cover_category = \"a\"\n\n    def save(self, author, photoid, url=None):\n        author.photos = [photoid] + [photo.id for photo in author.get_photos()]\n        author._save(\"Added new photo\", action=\"add-photo\", data={\"url\": url})\n\nclass manage_covers(delegate.page):\n    path = \"(/books/OL\\d+M)/manage-covers\"\n    def GET(self, key):\n        book = web.ctx.site.get(key)\n        if not book:\n            raise web.notfound()\n        return render_template(\"covers/manage\", key, self.get_images(book))\n\n    def get_images(self, book):\n        return book.get_covers()\n\n    def get_image(self, book):\n        return book.get_cover()\n\n    def save_images(self, book, covers):\n        book.covers = covers\n        book._save('Update covers')\n\n    def POST(self, key):\n        book = web.ctx.site.get(key)\n        if not book:\n            raise web.notfound()\n\n        images = web.input(image=[]).image\n        if '-' in images:\n            images = [int(id) for id in images[:images.index('-')]]\n            self.save_images(book, images)\n            return render_template(\"covers/saved\", self.get_image(book), showinfo=False)\n        else:\n            # ERROR\n            pass\n\nclass manage_work_covers(manage_covers):\n    path = \"(/works/OL\\d+W)/manage-covers\"\n\n\nclass manage_photos(manage_covers):\n    path = \"(/authors/OL\\d+A)/manage-photos\"\n\n    def get_images(self, author):\n        return author.get_photos()\n\n    def get_image(self, author):\n        return author.get_photo()\n\n    def save_images(self, author, photos):\n        author.photos = photos\n        author._save('Update photos')\n", "path": "openlibrary/plugins/upstream/covers.py"}]}