【发布时间】:2018-06-14 14:10:35
【问题描述】:
如何将 Blob 转换为字节数组?我试图上传视频并以字节数组格式调用 API
执行以下代码后,我们得到了“blob:http://localhost:8080/2d118b17-34b3-4e19-8044-72e9a0c5eaff”格式的视频。我想将blob url转换为字节数组。
谁能帮我把bloburl转换成字节数组?
我的 HTML:
<video ng-if="item.documentType == 'video'" controls width="100" height="145">
<source data-ng-src="{{item.data}}">
Your browser does not support the video tag.
</video>
我的 JS:
if(type == 'video'){
var item = {
name:file.files[0].name,
documentType:type,
src: file.files[0],
data: URL.createObjectURL(file.files[0]),
caseFileId: $scope.mediaItem.caseId
}
$scope.mediaItem.listDocumentDto.push(item);
}
【问题讨论】:
-
这里的一切都不像 Java
-
不要使用
URL.createObjectURL。直接上传文件。
标签: javascript html angularjs video