def getFile(self, file_id, **kwargs): """Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. Args: file_id: File identifier to get info about. Keyword Args: timeout (Optional[float]): If this value is specified, use it as the definitive timeout (in seconds) for urlopen() operations. Returns: :class:`telegram.File`: On success, a :class:`telegram.File` object is returned. Raises: :class:`telegram.TelegramError` """ url = '{0}/getFile'.format(self.base_url) data = {'file_id': file_id} result = request.post(url, data, timeout=kwargs.get('timeout')) if result.get('file_path'): result['file_path'] = '%s/%s' % (self.base_file_url, result['file_path']) return File.de_json(result)
def getFile(self, file_id): """Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. Args: file_id: File identifier to get info about. Returns: Returns a telegram.File object """ url = '%s/getFile' % self.base_url data = {'file_id': file_id} result = request.post(url, data) if result.get('file_path'): result['file_path'] = '%s/%s' % (self.base_file_url, result['file_path']) return File.de_json(result)
def getFile(self, file_id, **kwargs): """Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. Args: file_id: File identifier to get info about. Keyword Args: timeout (Optional[float]): If this value is specified, use it as the definitive timeout (in seconds) for urlopen() operations. Returns: :class:`telegram.File`: On success, a :class:`telegram.File` object is returned. Raises: :class:`telegram.TelegramError` """ url = '{0}/getFile'.format(self.base_url) data = {'file_id': file_id} result = request.post(url, data, timeout=kwargs.get('timeout')) if result.get('file_path'): result['file_path'] = '%s/%s' % (self.base_file_url, result['file_path']) return File.de_json(result)
def getFile(self, file_id): """Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. Args: file_id: File identifier to get info about. Returns: Returns a telegram.File object """ url = '%s/getFile' % self.base_url data = {'file_id': file_id} result = request.post(url, data) if result.get('file_path'): result['file_path'] = '%s/%s' % (self.base_file_url, result['file_path']) return File.de_json(result)
def test_de_json(self, bot): json_dict = { 'file_id': self.file_id, 'file_path': self.file_path, 'file_size': self.file_size } new_file = File.de_json(json_dict, bot) assert new_file.file_id == self.file_id assert new_file.file_path == self.file_path assert new_file.file_size == self.file_size
def test_de_json(self, bot): json_dict = { 'file_id': self.file_id, 'file_path': self.file_path, 'file_size': self.file_size } new_file = File.de_json(json_dict, bot) assert new_file.file_id == self.file_id assert new_file.file_path == self.file_path assert new_file.file_size == self.file_size
def test_de_json(self, bot): json_dict = { "file_id": self.file_id, "file_unique_id": self.file_unique_id, "file_path": self.file_path, "file_size": self.file_size, } new_file = File.de_json(json_dict, bot) assert new_file.file_id == self.file_id assert new_file.file_unique_id == self.file_unique_id assert new_file.file_path == self.file_path assert new_file.file_size == self.file_size