TypeError: FileBox.fromUrl is not a function

// 2. Send media file inside Room
import { FileBox }  from 'file-box'
const fileBox1 = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png')
const fileBox2 = FileBox.fromLocal('/tmp/text.txt')
await room.say(fileBox1)
await room.say(fileBox2)

以上代码使用会报错

TypeError: FileBox.fromUrl is not a function

 

以下才是正确用法

const { FileBox }  = require('file-box')
 
const fileBox1 = FileBox.fromUrl(
  'http://pic1.win4000.com/pic/6/3b/c6551219684.jpg',
  'logo.jpg',
)
fileBox1.toFile('logo.jpg')

 

posted @ 2020-03-29 14:39  纵一苇之所如-  阅读(374)  评论(0编辑  收藏  举报