'URL'에서 'createObjectURL'실행 실패 :
Safari에서 아래 오류 표시.
'URL'에서 'createObjectURL'실행 실패 : 제공된 서명과 일치하는 함수를 찾을 수 없습니다.
내 코드는 다음과 같습니다.
function createObjectURL(object) {
return (window.URL) ? window.URL.createObjectURL(object) : window.webkitURL.createObjectURL(object);
}
이것은 이미지에 대한 내 코드입니다.
function myUploadOnChangeFunction() {
if (this.files.length) {
for (var i in this.files) {
if (this.files.hasOwnProperty(i)) {
var src = createObjectURL(this.files[i]);
var image = new Image();
image.src = src;
imagSRC = src;
$('#img').attr('src', src);
}
}
}
}
createObjectURL
원시 데이터에 전달할 때 동일한 오류가 발생했습니다 .
window.URL.createObjectURL(data)
그것은이어야한다 Blob
, File
또는 MediaSource
객체가 아닌 데이터 자체. 이것은 나를 위해 일했습니다.
var binaryData = [];
binaryData.push(data);
window.URL.createObjectURL(new Blob(binaryData, {type: "application/zip"}))
자세한 정보는 MDN을 확인하십시오 : https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL
이 오류는 createObjectURL
Google 크롬에서 해당 기능 이 더 이상 사용되지 않기 때문에 발생합니다.
나는 이것을 바꿨다.
video.src=vendorUrl.createObjectURL(stream);
video.play();
이에:
video.srcObject=stream;
video.play();
이것은 나를 위해 일했습니다.
더 이상 사용되지 않는 기술을 사용했기 때문에 코드가 손상되었습니다. 예전에는 다음과 같습니다.
video.src = window.URL.createObjectURL(localMediaStream);
video.play();
그런 다음 이것을 다음으로 대체했습니다.
video.srcObject = localMediaStream;
video.play();
그것은 아름답게 작동했습니다.
편집 : 최근 localMediaStream
에 더 이상 사용되지 않고 MediaStream
. 최신 코드는 다음과 같습니다.
video.srcObject = MediaStream;
참조 :
- 더 이상 사용되지 않는 기술 : https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL
- 더 이상 사용되지 않는 최신 기술 : https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/srcObject
- 최신 기술 : https://developer.mozilla.org/en-US/docs/Web/API/MediaStream
MediaStream에 대해 동일한 오류가 발생했습니다. 솔루션은 srcObject에 스트림을 설정합니다.
로부터 문서 :
중요 : 미디어 요소에 스트림을 첨부하기 위해 createObjectURL ()에 의존하는 코드가있는 경우, 단순히 srcObject를 MediaStream에 직접 설정하도록 코드를 업데이트해야합니다.
대체가 포함 된 동영상 :
try {
video.srcObject = mediaSource;
} catch (error) {
video.src = URL.createObjectURL(mediaSource);
}
video.play();
From: https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/srcObject
The problem is that the keys provided in the loop do not refer to the index of the file.
for (var i in this.files) {
console.log(i);
}
The output of the above code is:
0
length
item
But what was expected was:
0
1
2
etc...
Then the error occurs when the browser tries to execute, for example:
window.URL.createObjectURL(this.files["length"])
I suggest implementation based on the following code:
var files = this.files;
for (var i = 0; i < files.length; i++) {
var file = files[i],
src = (window.URL || window.webkitURL).createObjectURL(file);
...
}
I hope this can help someone.
Greetings!
If you are using ajax, it is possible to add the options xhrFields: { responseType: 'blob' }
:
$.ajax({
url: 'yourURL',
type: 'POST',
data: yourData,
xhrFields: { responseType: 'blob' },
success: function (data, textStatus, jqXHR) {
let src = window.URL.createObjectURL(data);
}
});
I fixed it downloading the latest version from GgitHub GitHub url
참고URL : https://stackoverflow.com/questions/27120757/failed-to-execute-createobjecturl-on-url
'program story' 카테고리의 다른 글
Razor / MVC3를 사용하여 AssemblyVersion을 웹 페이지로 가져 오는 데 문제가 있습니다. (0) | 2020.08.20 |
---|---|
두 개의 복잡한 개체를 비교하는 가장 좋은 방법 (0) | 2020.08.20 |
ES6 화살표 함수와 함께 jQuery $ (this) 사용 (이 바인딩 어휘) (0) | 2020.08.20 |
jQuery에서 목록 요소 내용의 배열 가져 오기 (0) | 2020.08.20 |
GoogleSignatureVerifier 서명이 유효하지 않음 메시지 (Google Play 서비스 9.0.0) (0) | 2020.08.19 |