XMLHttpRequest具有Blob URL的404状态 [英] XMLHttpRequest Status of 404 With Blob URL

查看:972
本文介绍了XMLHttpRequest具有Blob URL的404状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将getUserMedia生成的blob URL上传到服务器。
其他人想要做同样的事情,这个问题一直是回答。

I'm trying to upload a blob URL generated by getUserMedia to the server. Someone else wanted to do the same thing, and that question has been answered.

我使用与回答该问题的人相同的XHR请求代码,但我得到的是404. 我做了一个小提琴,当你看到控制台时也会发生同样的事情。我在我的网站上也有一个现场示例,同样的事情发生了。

I am using the same code for the XHR request as the person who answered that question, but I'm getting a 404. I made a fiddle, and the same thing happens when you look at the console. I have a live example on my site as well, and the same thing happens.

以下是需要一些TLC的代码:

Here is the piece of code that needs some TLC:

function XHR(){
var xhr = new XMLHttpRequest();
xhr.open('GET',record.src); //404 ???
xhr.responseType = 'blob';
xhr.onload = function(e) {
    if (this.status == 200){
        //do some stuff
        result.innerText = this.response;
    }
};
xhr.send();
}

其他人似乎都可以这样做,因为之前已经讨论过。

Everybody else seems to be able to do this, because this has been discussed before.

图表A

图表B

我正在使用ChromeOS,41.0.2252.2 dev。到底发生了什么,为什么我不能得到这个blob?

I'm using ChromeOS, 41.0.2252.2 dev. What exactly is going on, and why can't I get the blob?

推荐答案

我几乎可以肯定MediaStream中的媒体不能保存在任何地方,只是在使用后丢弃。

有一个API用于记录流, MediaRecorder

只有Firefox有最基本的实现,所以它还没有用。

如果你正在实施在移动设备上,您可以使用带有capture属性的文件输入。

I'm almost certain the media in a MediaStream isn't saved anywhere, just thrown away after use.
There is a API in the works to record streams, MediaRecorder .
Only Firefox has the most basic implementation of this so it isn't usable as yet.
If you're implementing this on a mobile device you can use a file input with the capture attribute.

<input type="file" accept="video/*" capture>

这篇关于XMLHttpRequest具有Blob URL的404状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆