我想使用Angular-4将视频上传到azure blob存储,并且它可以在除IE之外的所有浏览器中正常工作
SCRIPT7002:XMLHttpRequest:网络错误0x80070005,访问被拒绝。
我正在使用put blob方法上传视频,这是它的代码。我搜索了此错误,发现了许多解决方案,但在这里不起作用我尝试过但未起作用的某些链接
Prevent IE11 caching GET call in Angular 2
Angular IE Caching issue for $http
upload(config: UploadConfig) {
debugger;
var options = new RequestOptions();
if (options == null) {
options = new RequestOptions();
}
const state = this.initializeState(config);
const reader = new FileReader();
reader.onloadend = (evt: any) => {
if (evt.target.readyState === 2 && !state.cancelled) {
debugger;
const uri = state.fileUrl + '&comp=block&blockid=' + state.blockIds[state.blockIds.length - 1];
const requestData = evt.target.result;
options.headers = new Headers();
const requestData2 = new Uint8Array(evt.target.result);
options.headers.append('x-ms-blob-type', 'BlockBlob');
options.headers.append('Content-Type', 'application/octet-stream');
this.http.put(uri, requestData, options).retryWhen(error => {
return error
.flatMap((error: any) => {
if (error.status === 503) {
return Observable.of(error.status).delay(1000)
}
return Observable.throw({ error: 'No retry' });
})
.take(5)
.concat(Observable.throw({ error: 'Sorry, there was an error (after 5 retries)' }));
})
.subscribe(elem => {
state.bytesUploaded += requestData2.length;
const percentComplete = ((state.bytesUploaded / state.file.size) * 100).toFixed(2);
if (state.progress) {
state.progress();
}
this.uploadFileInBlocks(reader, state);
}, err => {
this.messageService.showClientSideErrors('Oops something went wrong while uploading, please try again.')
this.loaderService.displayBar(false);
});
}
};
this.uploadFileInBlocks(reader, state);
return {
cancel: () => {
state.cancelled = true;
}
};
}
我已经调试了这段代码,并发现下面的代码行
this.http.put(uri, requestData, options).retryWhen(error => {
return error
.flatMap((error: any) => {
if (error.status === 503) {
return Observable.of(error.status).delay(1000)
}
return Observable.throw({ error: 'No retry' });
})
.take(5)
.concat(Observable.throw({ error: 'Sorry, there was an error (after 5 retries)' }));
})
我得到status = 0,并且在另一个浏览器中工作正常。有什么问题? IE-11 Win-10版本
答案 0 :(得分:0)
似乎您正在尝试自己构建HTTP请求。为什么不考虑使用Azure存储JavaScript SDK?
https://www.npmjs.com/package/@azure/storage-blob
dat %>%
group_by(user_id, mobile_id) %>%
arrange(created_at) %>%
filter(difftime > -600)