MCPcopy Create free account
hub / github.com/chatmail/core / send_file

Method send_file

python/src/deltachat/chat.py:297–310  ·  view source on GitHub ↗

send a file and return the resulting Message instance. :param path: path to the file. :param mime_type: the mime-type of this file, defaults to application/octet-stream. :raises ValueError: if message can not be send/chat does not exist. :returns: the resulting :clas

(self, path, mime_type="application/octet-stream")

Source from the content-addressed store, hash-verified

295 return Message.from_db(self.account, msg_id)
296
297 def send_file(self, path, mime_type="application/octet-stream"):
298 """send a file and return the resulting Message instance.
299
300 :param path: path to the file.
301 :param mime_type: the mime-type of this file, defaults to application/octet-stream.
302 :raises ValueError: if message can not be send/chat does not exist.
303 :returns: the resulting :class:`deltachat.message.Message` instance
304 """
305 msg = Message.new_empty(self.account, view_type="file")
306 msg.set_file(path, mime_type)
307 sent_id = lib.dc_send_msg(self.account._dc_context, self.id, msg._dc_msg)
308 if sent_id == 0:
309 raise ValueError("message could not be sent")
310 return Message.from_db(self.account, sent_id)
311
312 def send_image(self, path):
313 """send an image message and return the resulting Message instance.

Calls 3

new_emptyMethod · 0.80
set_fileMethod · 0.80
from_dbMethod · 0.80