def upload(self, image, name=None):
assert self.client_id, "<STR_LIT>"<EOL>assert self.client_secret, "<STR_LIT>"<EOL>try:<EOL><INDENT>image_data = (image + '<STR_LIT>')<EOL><DEDENT>except (TypeError, ValueError):<EOL><INDENT>assert hasattr(image, "<STR_LIT>"), "<STR_LIT>"<EOL>image_type = "<STR_LIT:file>"<EOL>image_data = image  <EOL>image_repr = repr(image)<EOL><DEDENT>else:<EOL><INDENT>if image.startswith("<STR_LIT>") or image.startswith("<STR_LIT>"):<EOL><INDENT>image_type = "<STR_LIT:url>"<EOL>image_data = image<EOL>image_repr = image<EOL><DEDENT>elif all(ord(i) >= <NUM_LIT:32> for i in image) and os.path.exists(image):<EOL><INDENT>image_type = "<STR_LIT:file>"<EOL>image_data = image  <EOL>image_repr = "<STR_LIT>" + image<EOL><DEDENT>else:<EOL><INDENT>image_type = "<STR_LIT>"<EOL>image_data = image_data.encode(image_type)<EOL>image_repr = "<STR_LIT>"<EOL><DEDENT><DEDENT>client = ImgurClient(self.client_id, self.client_secret)<EOL>result = (client.upload_from_url if image_type == '<STR_LIT:url>'<EOL>else client.upload_from_path)(image_data)  <EOL>if result['<STR_LIT>'].startswith('<STR_LIT>'):<EOL><INDENT>result['<STR_LIT>'] = '<STR_LIT>' + result['<STR_LIT>'][<NUM_LIT:5>:]<EOL><DEDENT>result['<STR_LIT>'] = result['<STR_LIT:id>']  <EOL>result['<STR_LIT>'] = result['<STR_LIT:description>']  <EOL>return parts.Bunch(<EOL>image=parts.Bunch(result),<EOL>links=parts.Bunch(<EOL>delete_page=None,<EOL>imgur_page=None,<EOL>original=result['<STR_LIT>'],<EOL>large_thumbnail="<STR_LIT>".format(*result['<STR_LIT>'].rsplit('<STR_LIT:.>', <NUM_LIT:1>)),<EOL>small_square="<STR_LIT>".format(*result['<STR_LIT>'].rsplit('<STR_LIT:.>', <NUM_LIT:1>)),<EOL>))<EOL>
Upload the given image, which can be a http[s] URL, a path to an existing file,
            binary image data, or an open file handle.