账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    node 下载的音频文件播放不了
    43
    0
    let message = await sequlize.models.chat_message.find({ where: { type: 'voice', them: 'video', phone: '17660590622' }, raw: true })
       for (let index = 0; index < message.length; index++) {
                const element = message[index];
    
                var file_url = message.message;
                var DOWNLOAD_DIR = './downloads/';
                download_file_httpget(file_url,index);
             }
             
    var download_file_httpget = function (file_url,index) {
        try {
    
    
            var DOWNLOAD_DIR = './downloads/';
            var options = {
                host: url.parse(file_url).host,
                port: 80,
                path: url.parse(file_url).pathname
            };
    
            var file_name = `${index}.mp3`;
            var file = fs.createWriteStream(DOWNLOAD_DIR + file_name);
    
            http.get(options, function (res) {
                res.on('data', function (data) {
                    file.write(data);
                }).on('end', function () {
                    file.end();
                    console.log(file_name + ' downloaded to ' + DOWNLOAD_DIR);
                });
            });
        } catch (error) {
            console.log('err***********', error)
        }
    };  

    用node的steam模块下载音频文件播放不了,message是一个数组,如果下载单个文件可以播放,这是为什么?

    0
    打赏
    收藏
    点击回答
        全部回答
    • 共 0 条
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部