想詢問
@handler.add(MessageEvent)
def handle_message(event):
user_id = event.source.user_id
if (event.message.type == "image"):
SendImage = line_bot_api.get_message_content(event.message.id)
print(SendImage)
local_save = ' ' + user_id + '.png'
with open(local_save, 'wb') as fd:
for check in SendImage.iter_content():
fd.write(check)
@handler.add(MessageEvent)
def handle_message(event):
UserId = event.source.user_id
if event.message.type == 'file':
UserSendFile = line_bot_api.get_message_content(event.message.id)
path = ' ' + UserId + '.docx'
with open(path, 'wb') as fd:
for chunk in UserSendFile.iter_content():
fd.write(chunk)
image 和 file 這兩個type 如何取得檔案名和 圖片名?
謝謝