I try to update the Firefox Marketplace entry of an app programatically via the Python API. I am able to successfully upload screenshots using the client.create_screenshot(app_id, filename)
method from the module marketplace
against the development environment at https://marketplace-dev.allizom.org/.
Within the Python API there is no method to upload the Icon. In the Marketplace API documentation though, there is a REST point to upload the icon: Updating an App Icon
I used the documentation to write my own method to upload the icon:
import mimetypes
import sys
from base64 import b64encode
from urlparse import urlunparse
def post_icon_file(client, app_id, filename):
with open(filename, 'rb') as s_file:
s_content = s_file.read()
s_encoded = b64encode(s_content)
url = urlunparse((client.protocol, '%s:%s' % (client.domain, client.port),
'%s/api/v2%s' % (client.prefix, '/apps/app/' + str(app_id) + '/icon/'),
'', '', ''))
print url
mtype, encoding = mimetypes.guess_type(filename)
if mtype is None:
mtype = 'image/jpeg'
data = {'file': {
'type': mtype,
'data': s_encoded
}}
response = client.conn.fetch('PUT', url, data)
if response.status_code != 200:
sys.exit(response.content)
else:
print str(response.status_code) + ': Uploaded icon ' + filename + ' for app ID ' + str(app_id)
Problem: The response of the upload is a success (200). I get the message:
200: Uploaded icon /path/to/icon/icon-512.png for app ID 1234567
Still in the Marketplace entry at https://marketplace-dev.allizom.org/developers/app/[slug]/edit, the App Icon is shown as the default icon
My Investigation so far:
If I get the status of the app via
client.status(app_id)
the entries for the icons are still the default ones, e.g.: icons: {u\'128\': u\'https://marketplace-dev-cdn.allizom.org/media/img/hub/default-128.png\'I tried to upload an icon in the size of 128 by 128 pixels and another one in 512 by 512 pixels. Both have the same result: success, but they are not changed in the entry.