iT邦幫忙

0

LineBot file和 image問題

C 2022-04-15 13:16:19588 瀏覽
  • 分享至 

  • xImage

想詢問
@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 如何取得檔案名和 圖片名?

謝謝

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友回答

立即登入回答