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)

Use the above code will complain

TypeError: FileBox.fromUrl is not a function

 

The following is the correct usage

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

 

Guess you like

Origin www.cnblogs.com/panjinzhao/p/12592219.html