读取文件然后创建该文件的Blob

时间:2012-12-18 00:49:52

标签: javascript ajax blob

如果我想读取文件(例如:audio.mp3)并且我知道它存在于何处,并且我想通过Blob中的javascript重新创建该文件,那么我可以将其附加到FormData中,这可能吗? / p>

            $.ajax({
                'type': 'GET',
                'url': sounds/audio.mp3
            }).done(function(body) {
                var blob = new Blob([body], {'type': 'audio/mpeg'});
                var formdata = new FormData();

                //Set other things then...
                data.append('audio.mp3', blob);
            }).fail(function(jqXHR, textStatus) {
                alert('failed');
            });

它正确地提交给我需要将其发送到的另一个Web服务器,并且我得到一个返回到该文件的URL,由Blob重新创建,但我不能再听声音了。这可能还是我只是抓住空气?

我是否有可能忘记放入一些内容来使音频数据结构正确?

0 个答案:

没有答案
相关问题