async def upload_file(self, bucket, file, uploadpath=None, key=None,<EOL>ContentType=None, **kw):
is_filename = False<EOL>if hasattr(file, '<STR_LIT>'):<EOL><INDENT>if hasattr(file, '<STR_LIT>'):<EOL><INDENT>file.seek(<NUM_LIT:0>)<EOL><DEDENT>file = file.read()<EOL>size = len(file)<EOL><DEDENT>elif key:<EOL><INDENT>size = len(file)<EOL><DEDENT>else:<EOL><INDENT>is_filename = True<EOL>size = os.stat(file).st_size<EOL>key = os.path.basename(file)<EOL><DEDENT>assert key, '<STR_LIT>'<EOL>if not ContentType:<EOL><INDENT>ContentType, _ = mimetypes.guess_type(key)<EOL><DEDENT>if uploadpath:<EOL><INDENT>if not uploadpath.endswith('<STR_LIT:/>'):<EOL><INDENT>uploadpath = '<STR_LIT>' % uploadpath<EOL><DEDENT>key = '<STR_LIT>' % (uploadpath, key)<EOL><DEDENT>params = dict(Bucket=bucket, Key=key)<EOL>if not ContentType:<EOL><INDENT>ContentType = '<STR_LIT>'<EOL><DEDENT>params['<STR_LIT>'] = ContentType<EOL>if size > MULTI_PART_SIZE and is_filename:<EOL><INDENT>resp = await _multipart(self, file, params)<EOL><DEDENT>elif is_filename:<EOL><INDENT>with open(file, '<STR_LIT:rb>') as fp:<EOL><INDENT>params['<STR_LIT>'] = fp.read()<EOL><DEDENT>resp = await self.put_object(**params)<EOL><DEDENT>else:<EOL><INDENT>params['<STR_LIT>'] = file<EOL>resp = await self.put_object(**params)<EOL><DEDENT>if '<STR_LIT>' not in resp:<EOL><INDENT>resp['<STR_LIT>'] = key<EOL><DEDENT>if '<STR_LIT>' not in resp:<EOL><INDENT>resp['<STR_LIT>'] = bucket<EOL><DEDENT>return resp<EOL>
Upload a file to S3 possibly using the multi-part uploader
        Return the key uploaded