Chuỗi javascript thành blob

blob is what are being many people search. 123 DocX. 123 DocX gửi tới các bạn bài viết Blob là gì. Tất tần tật về blob. Cùng123 DocX tìm hiểu ngay thôi

Đối tượng nhị phân lớn (BLOB)

Định nghĩa của Binary Large Object (BLOB) là gì?

Một đối tượng lớn nhị phân (BLOB) là một đối tượng lớn nhị phân (BLOB). Đây là    nghĩa tiếng Việt của   thuật ngữ Vật thể lớn nhị phân (BLOB), một thuật ngữ thuộc nhóm thuật ngữ kỹ thuật   – công nghệ thông tin. Element Element. 5/10

Đối tượng nhị phân lớn (BLOB) là một kiểu dữ liệu có thể lưu trữ các đối tượng hoặc dữ liệu nhị phân. LOB nhị phân được sử dụng trong cơ sở dữ liệu để lưu trữ dữ liệu nhị phân như hình ảnh, phương tiện tệp và mã thực thi

Xem thêm. AZ. thuật ngữ công nghệ

Giải thích ý nghĩa

Blobs chủ yếu được sử dụng trong tất cả các chương trình cơ sở dữ liệu. Nói chung, phần mềm cơ sở dữ liệu đối tượng nhị phân lớn có thể được chia thành hai loại. cấu trúc dữ liệu bán cấu trúc và dữ liệu cấu trúc phi cấu trúc. Tệp XML được phân loại là dữ liệu bán cấu trúc, trong khi định hình ảnh và phương tiện dữ liệu tiện ích được phân loại là kiểu dữ liệu có cấu trúc phân tích. Cả hai màu thường không được cơ sở dữ liệu giải thích. Vật thể lớn nhị phân (BLOB) là gì?

Đối tượng nhị phân lớn (BLOB) là một kiểu dữ liệu có thể lưu trữ các đối tượng hoặc dữ liệu nhị phân. LOB nhị phân được sử dụng trong cơ sở dữ liệu để lưu trữ dữ liệu nhị phân như hình ảnh, phương tiện tệp và mã thực thi. Hiểu các đối tượng nhị phân lớn (BLOB)

BOB được sử dụng trong tất cả các chương trình cơ sở dữ liệu. Thông thường, phần mềm cơ sở dữ liệu phân loại BLOB thành hai loại. cấu trúc dữ liệu bán cấu trúc và dữ liệu cấu trúc phi cấu trúc. Tệp XML được phân loại là dữ liệu bán cấu trúc, trong khi cấu hình ảnh và phương tiện được phân loại là kiểu dữ liệu phi cấu trúc. Cả hai màu này thường không được cơ sở dữ liệu giải thích. Các điều khoản liên quan

  • Đa phương tiện
  • Phần mềm cơ sở dữ liệu
  • nhị phân file
  • Đối tượng ký tự lớn (CLOB)
  • Hình ảnh do máy tính tạo ra (CGI)
  • Người xây dựng
  • Nhật thực
  • Tiếp chuyển
  • Hỗ trợ sự kiện tụng tự động (ALS)
  • bán sắc

Nguồn. Vật thể lớn nhị phân (BLOB) là gì?

Url blob là gì và tại sao nó được sử dụng?


348

Tôi có rất nhiều vấn đề với url blob

Tôi đã tìm kiếm video của    

duration:
8thẻ trên youtube và thấy rằng    
duration:
8nó giống như sau

src="blob:https://crap.crap"

Tôi đã mở url blob trong    

duration:
8video và nó đã thông báo lỗi cho tôi. Tôi không thể mở liên kết nhưng nó hoạt động với   
duration:
8thẻ. Làm thế nào nó có thể được?

Contra control

  • Url blob là gì?
  • Tại sao nó được sử dụng?
  • Tôi có thể tạo blog url của riêng mình trên máy chủ không?
  • If you have more information


– Nguồn Wakas Tahir



Câu trả lời


349

URL Blob (liên kết W3C, tên chính thức) hoặc đối tượng URL (liên kết MDN và tên phương thức) được sử dụng với các đối tượng Blob hoặc Tệp

src = “đốm màu. https. // tào lao. tào lao” Tôi đã mở url blob trong video src, nó bị lỗi và tôi không thể mở được, nhưng làm việc với thẻ src thì sao?

Chỉ có thể tạo các khối URL bên trong trình duyệt.

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
2 sẽ tạo một tham chiếu đặc biệt cho các đối tượng Blob hoặc File, sau đó các đối tượng này có thể được phân bổ
var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
3. Các URL này chỉ có thể được sử dụng bộ cục bộ trong một phiên bản duyệt và trong cùng một phiên bản (tức là trong suốt thời gian của trang / tài liệu)

Url blob là gì?
Tại sao nó được sử dụng?

Blob URL / URL là một giao thức giả cho phép các đối tượng Blob và Tệp được sử dụng làm URL nguồn cho những thứ như hình ảnh, liên kết tải xuống nhị phân, v. v

Ví dụ, bạn không thể xử lý byte dữ liệu thô của đối tượng hình ảnh vì nó sẽ không biết phải làm gì với nó. Nó yêu cầu hình ảnh ví dụ (là dữ liệu nhị phân) phải được tải xuống qua URL. Điều này được áp dụng cho bất kỳ điều gì yêu cầu URL là nguồn. Thay vì tải lên dữ liệu nhị phân, sau đó phân phát lại thông qua URL, tốt hơn là sử dụng một bước cục bộ bổ sung để có thể truy cập dữ liệu trực tiếp mà không cần thông qua máy chủ

Nó cũng là một sự thay thế tốt hơn cho Data-URI, các chuỗi được mã hóa thành Base-64. Vấn đề với Data-URI là mỗi char lấy hai byte trong JavaScript. Trên hết, 33% được thêm vào do mã hóa Base-64. Blobs là các mảng byte nhị phân thuần túy, không có bất kỳ chi phí đáng kể nào như Data-URI, điều này làm cho chúng nhanh hơn và nhỏ hơn để xử lý

Tôi có thể tạo url blob của riêng mình trên máy chủ không?

Không, URL Blob / URL object only can be used internal in browser. Bạn có thể tạo Blobs và nhận đối tượng Tệp thông tin qua Trình đọc tệp API, mặc dù BLOB chỉ có nghĩa là Đối tượng lớn nhị phân và được lưu trữ dưới dạng mảng byte. Một khách hàng có thể yêu cầu dữ liệu được gửi dưới dạng ArrayBuffer hoặc Blob. Máy chủ sẽ gửi dữ liệu dưới dạng dữ liệu nhị phân thuần túy. Cơ sở dữ liệu thường sử dụng Blob để mô tả các đối tượng nhị phân, và về bản chất chúng ta đang nói về cơ bản các mảng byte

if you have thì chi tiết bổ sung

Bạn cần đóng gói dữ liệu nhị phân dưới dạng đối tượng BLOB, sau đó sử dụng 

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
2 để tạo URL bộ cục bộ cho nó

________số 8

Lưu ý rằng 

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
5có thể có tiền tố trong trình duyệt webkit, vì vậy hãy sử dụng

duration:
0

— Bakudan
nguồn







10

Hàm Javascript này có nghĩa là hiển thị sự khác biệt giữa API tệp Blob và API Dữ liệu để tải xuống tệp JSON trong trình duyệt máy khách

duration:
1

Run đoạn mã mở rộng đoạn trích

Hàm được gọi là như 

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
6. Nó sẽ tạo ra một ByteStream ngay lập tức trình duyệt được duyệt và sẽ tải xuống tệp được tạo trực tiếp bằng tệp API 
var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
7

Trong 

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
8đó, có thể thấy kết quả tương ứng được thông qua_______59 phần tử cộng với dữ liệu API, nhưng điều này có một số giới hạn mà API Blob không có. — loretoparisi
nguồn



3

Url blob là gì?

BLOB chỉ là byte chuỗi. Trình duyệt nhận ra nó là byte luồng. It is used to get stream byte from source

Một đối tượng Blob đại diện cho một đối tượng giống như tệp của dữ liệu thô, không thay đổi. Các đốm màu đại diện cho dữ liệu không nhất thiết phải ở định dạng JavaScript gốc. Giao diện Tệp dựa trên Blob, kế thừa chức năng blob và mở rộng nó để hỗ trợ các tệp trên hệ thống của người dùng

Tôi có thể tạo url blob của riêng mình trên máy chủ không?

Có, bạn có thể có các cách máy chủ để làm như vậy, ví dụ: hãy thử http. //php. net/thủ công/vi/chức năng. ibase-blob-echo. php

Đọc thêm về

  • https. // nhà phát triển. mozilla. org/pl/docs/Web/API/Blob
  • http. //www. w3. org/TR/FileAPI/#dfn-Blob
  • https. // url. thông số kỹ thuật. cái gì. tổ chức/#urls

— Robert
nguồn






2

Tôi đã sửa đổi giải pháp làm việc để xử lý cả hai trường hợp. khi video được tải lên và khi hình ảnh được tải lên. hy vọng nó sẽ giúp một số

HTML

duration:

Javascript

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};

url jsFiddle

https. //jsfiddle. net/PratapDessai/0sp3b159/— Dapai
nguồn

Đối tượng lớn nhị phân (BLOB)

Định nghĩa của đối tượng lớn nhị phân (BLOB) là gì?

Đối tượng lớn nhị phân (BLOB) là đối tượng lớn nhị phân (BLOB). Đây là nghĩa tiếng Việt của thuật ngữ Đối tượng lớn nhị phân (BLOB) – một thuật ngữ thuộc nhóm Thuật ngữ công nghệ – Công nghệ thông tin. yếu tố đánh giá. 5/10

Một đối tượng lớn nhị phân (BLOB) là một kiểu dữ liệu có thể lưu trữ các đối tượng hoặc dữ liệu nhị phân. Các đối tượng lớn nhị phân được sử dụng trong cơ sở dữ liệu để lưu trữ dữ liệu nhị phân như hình ảnh, tệp đa phương tiện và mã phần mềm thực thi

Xem thêm. AZ. thuật ngữ công nghệ

Giải thích ý nghĩa

Các đối tượng nhị phân lớn chủ yếu được sử dụng trong tất cả các phần mềm cơ sở dữ liệu. Nói chung, phần mềm cơ sở dữ liệu nhị phân đối tượng lớn có thể được phân thành hai loại. dữ liệu bán cấu trúc và dữ liệu phi cấu trúc. Các tệp XML được phân loại là dữ liệu bán cấu trúc, trong khi dữ liệu hình ảnh và đa phương tiện là các loại dữ liệu có cấu trúc. Cả hai đốm màu thường không thể hiểu được bởi cơ sở dữ liệu. Đối tượng lớn nhị phân (BLOB) là gì?

Một đối tượng lớn nhị phân (BLOB) là một kiểu dữ liệu có thể lưu trữ các đối tượng hoặc dữ liệu nhị phân. Các đối tượng lớn nhị phân được sử dụng trong cơ sở dữ liệu để lưu trữ dữ liệu nhị phân như hình ảnh, tệp đa phương tiện và mã phần mềm thực thi. Hiểu đối tượng lớn nhị phân (BLOB)

Các đối tượng lớn nhị phân là ưu việt trong tất cả các phần mềm cơ sở dữ liệu. Nói chung, phần mềm cơ sở dữ liệu phân loại các đối tượng lớn nhị phân thành hai loại. dữ liệu bán cấu trúc và dữ liệu phi cấu trúc. Các tệp XML được phân loại là dữ liệu bán cấu trúc, trong khi hình ảnh và dữ liệu đa phương tiện là các loại dữ liệu phi cấu trúc. Cả hai BLOB này thường không thể hiểu được bởi cơ sở dữ liệu. thuật ngữ liên quan

  • đa phương tiện
  • Phần mềm cơ sở dữ liệu
  • Tệp nhị phân
  • Đối tượng lớn ký tự (CLOB)
  • Hình ảnh do máy tính tạo ra (CGI)
  • Người xây dựng
  • nhật thực
  • Tạm thời
  • Hỗ trợ kiện tụng tự động (ALS)
  • bán sắc

Nguồn. Đối tượng lớn nhị phân (BLOB) là gì?

URL blob là gì và tại sao nó được sử dụng?


348

Tôi đang gặp rất nhiều vấn đề với URL blob

Tôi đã tìm kiếm 

duration:
8một thẻ video trên YouTube và tôi thấy rằng video đó 
duration:
8giống như vậy

src="blob:https://crap.crap"

Tôi đã mở URL blob trong 

duration:
8video mà nó báo lỗi. Tôi không thể mở liên kết, nhưng nó đã hoạt động với 
duration:
8thẻ. Sao có thể như thế được?

Request

  • URL blob là gì?
  • Tại sao nó được sử dụng?
  • Tôi có thể tạo blob URL của riêng mình trên máy chủ không?
  • Nếu bạn có bất kỳ chi tiết bổ sung nào

— Waqas Tahir
nguồn



Câu trả lời


349

URL Blob (ref W3C , tên chính thức) hoặc đối tượng URL (ref. MDN và tên phương thức) được sử dụng với các đối tượng Blob hoặc Tệp

src = “đốm màu. https. // tào lao. tào lao ” Tôi đã mở url blob trong src của video, nó bị lỗi và tôi không thể mở nhưng đang làm việc với thẻ src thì sao?

URL Blob chỉ có thể được tạo bởi trình duyệt nội bộ.

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
2 sẽ tạo một tham chiếu đặc biệt cho các đối tượng Blob hoặc File mà sau này có thể được phát hành theo cách sử dụng 
var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
3. Các URL này chỉ có thể được sử dụng bộ cục bộ trong phiên bản duy nhất của trình duyệt và trong cùng một phiên bản (tức là tuổi thọ của trang / tài liệu)

Url blob là gì?
Tại sao nó được sử dụng?

URL / URL đối tượng Blob là một giao thức giả để cho phép các đối tượng Blob và Tệp được sử dụng làm URL nguồn cho những thứ như hình ảnh, liên kết tải xuống cho dữ liệu nhị phân, v. v

Ví dụ, bạn không thể xử lý byte dữ liệu thô của đối tượng hình ảnh vì nó sẽ không biết phải làm gì với nó. Nó yêu cầu hình ảnh ví dụ (là dữ liệu nhị phân) phải được tải xuống qua URL. Điều này được áp dụng cho bất kỳ điều gì yêu cầu URL là nguồn. Thay vì tải lên dữ liệu nhị phân, sau đó phân phát lại thông qua URL, tốt hơn là sử dụng một bước cục bộ bổ sung để có thể truy cập dữ liệu trực tiếp mà không cần thông qua máy chủ

Nó cũng là một sự thay thế tốt hơn cho Data-URI, các chuỗi được mã hóa thành Base-64. Vấn đề với Data-URI là mỗi char lấy hai byte trong JavaScript. Trên hết, 33% được thêm vào do mã hóa Base-64. Blobs là các mảng byte nhị phân thuần túy, không có bất kỳ chi phí đáng kể nào như Data-URI, điều này làm cho chúng nhanh hơn và nhỏ hơn để xử lý

Tôi có thể tạo url blob của riêng mình trên máy chủ không?

Không, URL Blob / URL object only can be used internal in browser. Bạn có thể tạo Blobs và nhận đối tượng Tệp thông tin qua Trình đọc tệp API, mặc dù BLOB chỉ có nghĩa là Đối tượng lớn nhị phân và được lưu trữ dưới dạng mảng byte. Một khách hàng có thể yêu cầu dữ liệu được gửi dưới dạng ArrayBuffer hoặc Blob. Máy chủ sẽ gửi dữ liệu dưới dạng dữ liệu nhị phân thuần túy. Cơ sở dữ liệu thường sử dụng Blob để mô tả các đối tượng nhị phân, và về bản chất chúng ta đang nói về cơ bản các mảng byte

if you have thì chi tiết bổ sung

Bạn cần đóng gói dữ liệu nhị phân dưới dạng đối tượng BLOB, sau đó sử dụng 

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
2 để tạo URL bộ cục bộ cho nó

________số 8

Lưu ý rằng 

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
5có thể có tiền tố trong trình duyệt webkit, vì vậy hãy sử dụng

duration:
0

— Bakudan
nguồn







10

Hàm Javascript này có nghĩa là hiển thị sự khác biệt giữa API tệp Blob và API Dữ liệu để tải xuống tệp JSON trong trình duyệt máy khách

duration:
1

Run đoạn mã mở rộng đoạn trích

Hàm được gọi là như 

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
6. Nó sẽ tạo ra một ByteStream ngay lập tức trình duyệt được duyệt và sẽ tải xuống tệp được tạo trực tiếp bằng tệp API 
var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
7

Trong 

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
8đó, có thể thấy kết quả tương ứng được thông qua_______59 phần tử cộng với dữ liệu API, nhưng điều này có một số giới hạn mà API Blob không có. — loretoparisi
nguồn



3

Url blob là gì?

BLOB chỉ là byte chuỗi. Trình duyệt nhận ra nó là byte luồng. It is used to get stream byte from source

Объект Blob представляет собой файловый объект необработанных неизменяемых данных. BLOB-объекты представляют данные, которые явно не в родном формате JavaScript. Интерфейс File основан на Blob, который наследует функциональные возможности больших двоичных объектов и расширяет их для поддержки файлов в системе пользователя

Tại sao bạn không thể truy cập vào trang web của mình?

Да, у вас могут быть серверные способы сделать это, например, попробуйте http. //php. net/thủ công/vi/chức năng. ibase-blob-echo. php

Подробнее о

  • https. // nhà phát triển. mozilla. org/pl/docs/Web/API/Blob
  • http. //www. w3. org/TR/FileAPI/#dfn-Blob
  • https. // url. thông số kỹ thuật. cái gì. tổ chức/#urls

— Роберт
источник






2

З

HTML

duration:

Javascript

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};

URL-aдрес jsFiddle

https. //jsfiddle. net/PratapDessai/0sp3b159/ — источник Дапай

Làm thế nào để bạn có thể phát trực tuyến (BLOB)?

Большой двоичный объект (BLOB) — это большой двоичный объект (BLOB). Э. Рейтинг фактора. 5/10

Двоичный большой объект (BLOB) — это тип данных, который может хранить двоичные объекы или неан. Двоичные большие объекты используются в базах данных для хранения двоичных данных, таких как изображения, мультимедийные файлы и исполняемый программный код

Смотрите также. АЗ. технологическая терминология

Объясните значение

Большие двоичные объекты в основном используются во всех программах баз данных. В р л. полуструктурированные данные và неструктурированные данные. XML-й. Оба больших двоичных объекта обычно не интерпретируются базой данных. Bạn có biết thế giới của mình là BLOB không?

Двоичный большой объект (BLOB) — это тип данных, который может хранить двоичные объекы или неан. Двоичные большие объекты используются в базах данных для хранения двоичных данных, таких как изображения, мультимедийные файлы и исполняемый программный код. Общие сведения о больших двоичных объектах (BLOB)

Двоичные большие объекты используются во всех программах баз данных. Как правило, программное обеспечение базы данных классифицирует большие двоичдые объектыаиа наиа. частично структурированные данные và неструктурированные данные. XML-файлы классифицируются как частично структурированные данные, тогда как изображения и мультимедийные данные относятся к неструктурированным типам данных. Оба этих больших двоичных объекта обычно не интерпретируются базой данных. Связанные термины

  • Мультимедиа
  • Программное обеспечение базы данных
  • Двоичные файлы
  • Символьный большой объект (CLOB)
  • Kỹ xảo điện ảnh (CGI)
  • Конструктор
  • Затмение
  • Переходный
  • Bệnh ALS (ALS)
  • Полутона

Источник. bạn có biết thế giới của mình (BLOB) không?

Bạn có biết URL-aдрес большого двоичного объекта và почему он используется?


348

У меня много проблем с URL-адресами больших двоичных объектов

Я искал  

duration:
8тег видео trên YouTube và обнаружил, что  
duration:
8он выглядит так

src="blob:https://crap.crap"

Я открыл URL-адрес большого двоичного объекта в  

duration:
8видео, и он выдал мне ошибку. Я не мог открыть ссылку, но она работала с  
duration:
8тегом. Bạn có muốn làm gì không?

Запрос

  • Bạn có biết URL-адрес большого двоичного объекта không?
  • Bạn có muốn làm gì không?
  • Tại sao bạn không thể truy cập vào trang web của mình?
  • Если у вас есть дополнительная информация


– Источник Вакас Тахир



Отвечать


349

Url-адрес blob-о

src=”đốm màu. https. // tào lao. tào lao о о

URL-адреса больших двоичных объектов могут создаваться только внутри браузера. 3 3. Ur. e. в течение срока действия страницы/документа)

Что такое URL-адрес BLOB-объекта?
Почему это используется?

URL/URL объекта Blob — это псевдопротокол, позволяющий использовать объекты Blob и File в качестве источников URL для таких вещей, как изображения, ссылки для скачивания двоичных данных и т. д

Ví dụ, bạn không thể xử lý byte dữ liệu thô của đối tượng hình ảnh vì nó sẽ không biết phải làm gì với nó. Nó yêu cầu hình ảnh ví dụ (là dữ liệu nhị phân) phải được tải xuống qua URL. Điều này được áp dụng cho bất kỳ điều gì yêu cầu URL là nguồn. Thay vì tải lên dữ liệu nhị phân, sau đó phân phát lại thông qua URL, tốt hơn là sử dụng một bước cục bộ bổ sung để có thể truy cập dữ liệu trực tiếp mà không cần thông qua máy chủ

Nó cũng là một sự thay thế tốt hơn cho Data-URI, các chuỗi được mã hóa thành Base-64. Vấn đề với Data-URI là mỗi char lấy hai byte trong JavaScript. Trên hết, 33% được thêm vào do mã hóa Base-64. Blobs là các mảng byte nhị phân thuần túy, không có bất kỳ chi phí đáng kể nào như Data-URI, điều này làm cho chúng nhanh hơn và nhỏ hơn để xử lý

Tôi có thể tạo url blob của riêng mình trên máy chủ không?

Không, URL Blob / URL object only can be used internal in browser. Bạn có thể tạo Blobs và nhận đối tượng Tệp thông tin qua Trình đọc tệp API, mặc dù BLOB chỉ có nghĩa là Đối tượng lớn nhị phân và được lưu trữ dưới dạng mảng byte. Một khách hàng có thể yêu cầu dữ liệu được gửi dưới dạng ArrayBuffer hoặc Blob. Máy chủ sẽ gửi dữ liệu dưới dạng dữ liệu nhị phân thuần túy. Cơ sở dữ liệu thường sử dụng Blob để mô tả các đối tượng nhị phân, và về bản chất chúng ta đang nói về cơ bản các mảng byte

if you have thì chi tiết bổ sung

Bạn cần đóng gói dữ liệu nhị phân dưới dạng đối tượng BLOB, sau đó sử dụng 

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
2 để tạo URL bộ cục bộ cho nó

________số 8

Lưu ý rằng 

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
5có thể có tiền tố trong trình duyệt webkit, vì vậy hãy sử dụng

duration:
0

— Bakudan
nguồn







10

Hàm Javascript này có nghĩa là hiển thị sự khác biệt giữa API tệp Blob và API Dữ liệu để tải xuống tệp JSON trong trình duyệt máy khách

duration:
1

Run đoạn mã mở rộng đoạn trích

Hàm được gọi là như 

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
6. Nó sẽ tạo ra một ByteStream ngay lập tức trình duyệt được duyệt và sẽ tải xuống tệp được tạo trực tiếp bằng tệp API 
var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
7

Trong 

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
8đó, có thể thấy kết quả tương ứng được thông qua_______59 phần tử cộng với dữ liệu API, nhưng điều này có một số giới hạn mà API Blob không có. — loretoparisi
nguồn



3

Url blob là gì?

BLOB chỉ là byte chuỗi. Trình duyệt nhận ra nó là byte luồng. It is used to get stream byte from source

Một đối tượng Blob đại diện cho một đối tượng giống như tệp của dữ liệu thô, không thay đổi. Các đốm màu đại diện cho dữ liệu không nhất thiết phải ở định dạng JavaScript gốc. Giao diện Tệp dựa trên Blob, kế thừa chức năng blob và mở rộng nó để hỗ trợ các tệp trên hệ thống của người dùng

Tôi có thể tạo url blob của riêng mình trên máy chủ không?

Có, bạn có thể có các cách máy chủ để làm như vậy, ví dụ: hãy thử http. //php. net/thủ công/vi/chức năng. ibase-blob-echo. php

Đọc thêm về

  • https. // nhà phát triển. mozilla. org/pl/docs/Web/API/Blob
  • http. //www. w3. org/TR/FileAPI/#dfn-Blob
  • https. // url. thông số kỹ thuật. cái gì. tổ chức/#urls

— Robert
nguồn






2

Tôi đã sửa đổi giải pháp làm việc để xử lý cả hai trường hợp. khi video được tải lên và khi hình ảnh được tải lên. hy vọng nó sẽ giúp một số

HTML

duration:

Javascript

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};

url jsFiddle

https. //jsfiddle. net/PratapDessai/0sp3b159/— Dapai
nguồn

Đối tượng lớn nhị phân (BLOB)

Định nghĩa của đối tượng lớn nhị phân (BLOB) là gì?

Đối tượng lớn nhị phân (BLOB) là đối tượng lớn nhị phân (BLOB). Đây là nghĩa tiếng Việt của thuật ngữ Đối tượng lớn nhị phân (BLOB) – một thuật ngữ thuộc nhóm Thuật ngữ công nghệ – Công nghệ thông tin. yếu tố đánh giá. 5/10

Một đối tượng lớn nhị phân (BLOB) là một kiểu dữ liệu có thể lưu trữ các đối tượng hoặc dữ liệu nhị phân. Các đối tượng lớn nhị phân được sử dụng trong cơ sở dữ liệu để lưu trữ dữ liệu nhị phân như hình ảnh, tệp đa phương tiện và mã phần mềm thực thi

Xem thêm. AZ. thuật ngữ công nghệ

Giải thích ý nghĩa

Các đối tượng nhị phân lớn chủ yếu được sử dụng trong tất cả các phần mềm cơ sở dữ liệu. Nói chung, phần mềm cơ sở dữ liệu nhị phân đối tượng lớn có thể được phân thành hai loại. dữ liệu bán cấu trúc và dữ liệu phi cấu trúc. Các tệp XML được phân loại là dữ liệu bán cấu trúc, trong khi dữ liệu hình ảnh và đa phương tiện là các loại dữ liệu có cấu trúc. Cả hai đốm màu thường không thể hiểu được bởi cơ sở dữ liệu. Đối tượng lớn nhị phân (BLOB) là gì?

Một đối tượng lớn nhị phân (BLOB) là một kiểu dữ liệu có thể lưu trữ các đối tượng hoặc dữ liệu nhị phân. Các đối tượng lớn nhị phân được sử dụng trong cơ sở dữ liệu để lưu trữ dữ liệu nhị phân như hình ảnh, tệp đa phương tiện và mã phần mềm thực thi. Hiểu đối tượng lớn nhị phân (BLOB)

Các đối tượng lớn nhị phân là ưu việt trong tất cả các phần mềm cơ sở dữ liệu. Nói chung, phần mềm cơ sở dữ liệu phân loại các đối tượng lớn nhị phân thành hai loại. dữ liệu bán cấu trúc và dữ liệu phi cấu trúc. Các tệp XML được phân loại là dữ liệu bán cấu trúc, trong khi hình ảnh và dữ liệu đa phương tiện là các loại dữ liệu phi cấu trúc. Cả hai BLOB này thường không thể hiểu được bởi cơ sở dữ liệu. thuật ngữ liên quan

  • đa phương tiện
  • Phần mềm cơ sở dữ liệu
  • Tệp nhị phân
  • Đối tượng lớn ký tự (CLOB)
  • Hình ảnh do máy tính tạo ra (CGI)
  • Người xây dựng
  • nhật thực
  • Tạm thời
  • Hỗ trợ kiện tụng tự động (ALS)
  • bán sắc

Nguồn. Đối tượng lớn nhị phân (BLOB) là gì?

URL blob là gì và tại sao nó được sử dụng?


348

Tôi đang gặp rất nhiều vấn đề với URL blob

Tôi đã tìm kiếm 

duration:
8một thẻ video trên YouTube và tôi thấy rằng video đó 
duration:
8giống như vậy

src="blob:https://crap.crap"

Tôi đã mở URL blob trong 

duration:
8video mà nó báo lỗi. Tôi không thể mở liên kết, nhưng nó đã hoạt động với 
duration:
8thẻ. Sao có thể như thế được?

Request

  • URL blob là gì?
  • Tại sao nó được sử dụng?
  • Tôi có thể tạo blob URL của riêng mình trên máy chủ không?
  • Nếu bạn có bất kỳ chi tiết bổ sung nào

— Waqas Tahir
nguồn



Câu trả lời


349

URL Blob (ref W3C , tên chính thức) hoặc đối tượng URL (ref. MDN và tên phương thức) được sử dụng với các đối tượng Blob hoặc Tệp

src = “đốm màu. https. // tào lao. tào lao ” Tôi đã mở url blob trong src của video, nó bị lỗi và tôi không thể mở nhưng đang làm việc với thẻ src thì sao?

URL Blob chỉ có thể được tạo bởi trình duyệt nội bộ.

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
2 sẽ tạo một tham chiếu đặc biệt cho các đối tượng Blob hoặc File mà sau này có thể được phát hành theo cách sử dụng 
var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
3. Các URL này chỉ có thể được sử dụng bộ cục bộ trong phiên bản duy nhất của trình duyệt và trong cùng một phiên bản (tức là tuổi thọ của trang / tài liệu)

Url blob là gì?
Tại sao nó được sử dụng?

URL / URL đối tượng Blob là một giao thức giả để cho phép các đối tượng Blob và Tệp được sử dụng làm URL nguồn cho những thứ như hình ảnh, liên kết tải xuống cho dữ liệu nhị phân, v. v

Ví dụ, bạn không thể xử lý byte dữ liệu thô của đối tượng hình ảnh vì nó sẽ không biết phải làm gì với nó. Nó yêu cầu hình ảnh ví dụ (là dữ liệu nhị phân) phải được tải xuống qua URL. Điều này được áp dụng cho bất kỳ điều gì yêu cầu URL là nguồn. Thay vì tải lên dữ liệu nhị phân, sau đó phân phát lại thông qua URL, tốt hơn là sử dụng một bước cục bộ bổ sung để có thể truy cập dữ liệu trực tiếp mà không cần thông qua máy chủ

Nó cũng là một sự thay thế tốt hơn cho Data-URI, các chuỗi được mã hóa thành Base-64. Vấn đề với Data-URI là mỗi char lấy hai byte trong JavaScript. Trên hết, 33% được thêm vào do mã hóa Base-64. Blobs là các mảng byte nhị phân thuần túy, không có bất kỳ chi phí đáng kể nào như Data-URI, điều này làm cho chúng nhanh hơn và nhỏ hơn để xử lý

Tôi có thể tạo url blob của riêng mình trên máy chủ không?

Không, URL Blob / URL object only can be used internal in browser. Bạn có thể tạo Blobs và nhận đối tượng Tệp thông tin qua Trình đọc tệp API, mặc dù BLOB chỉ có nghĩa là Đối tượng lớn nhị phân và được lưu trữ dưới dạng mảng byte. Một khách hàng có thể yêu cầu dữ liệu được gửi dưới dạng ArrayBuffer hoặc Blob. Máy chủ sẽ gửi dữ liệu dưới dạng dữ liệu nhị phân thuần túy. Cơ sở dữ liệu thường sử dụng Blob để mô tả các đối tượng nhị phân, và về bản chất chúng ta đang nói về cơ bản các mảng byte

if you have thì chi tiết bổ sung

Bạn cần đóng gói dữ liệu nhị phân dưới dạng đối tượng BLOB, sau đó sử dụng 

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
2 để tạo URL bộ cục bộ cho nó

________số 8

Lưu ý rằng 

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
5có thể có tiền tố trong trình duyệt webkit, vì vậy hãy sử dụng

duration:
0

— Bakudan
nguồn







10

Hàm Javascript này có nghĩa là hiển thị sự khác biệt giữa API tệp Blob và API Dữ liệu để tải xuống tệp JSON trong trình duyệt máy khách

duration:
1

Run đoạn mã mở rộng đoạn trích

Hàm được gọi là như 

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
6. Nó sẽ tạo ra một ByteStream ngay lập tức trình duyệt được duyệt và sẽ tải xuống tệp được tạo trực tiếp bằng tệp API 
var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
7

Trong 

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
8đó, có thể thấy kết quả tương ứng được thông qua_______59 phần tử cộng với dữ liệu API, nhưng điều này có một số giới hạn mà API Blob không có. — loretoparisi
nguồn



3

Url blob là gì?

BLOB chỉ là byte chuỗi. Trình duyệt nhận ra nó là byte luồng. It is used to get stream byte from source

Объект Blob представляет собой файловый объект необработанных неизменяемых данных. BLOB-объекты представляют данные, которые явно не в родном формате JavaScript. Интерфейс File основан на Blob, который наследует функциональные возможности больших двоичных объектов и расширяет их для поддержки файлов в системе пользователя

Tại sao bạn không thể truy cập vào trang web của mình?

Да, у вас могут быть серверные способы сделать это, например, попробуйте http. //php. net/thủ công/vi/chức năng. ibase-blob-echo. php

Подробнее о

  • https. // nhà phát triển. mozilla. org/pl/docs/Web/API/Blob
  • http. //www. w3. org/TR/FileAPI/#dfn-Blob
  • https. // url. thông số kỹ thuật. cái gì. tổ chức/#urls

— Роберт
источник






2

З

HTML

duration:

Javascript

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};

Url JsFiddle

https. //jsfiddle. net/PratapDessai/0sp3b159/ –  Nguồn  Dapai

Đối tượng nhị phân lớn (BLOB)

Định nghĩa của Binary Large Object (BLOB) là gì?

Một đối tượng lớn nhị phân (BLOB) là một đối tượng lớn nhị phân (BLOB). Đây là    nghĩa tiếng Việt của   thuật ngữ Vật thể lớn nhị phân (BLOB), một thuật ngữ thuộc nhóm thuật ngữ kỹ thuật   – công nghệ thông tin. Element Element. 5/10

Đối tượng nhị phân lớn (BLOB) là một kiểu dữ liệu có thể lưu trữ các đối tượng hoặc dữ liệu nhị phân. LOB nhị phân được sử dụng trong cơ sở dữ liệu để lưu trữ dữ liệu nhị phân như hình ảnh, phương tiện tệp và mã thực thi

Xem thêm. AZ. thuật ngữ công nghệ

Giải thích ý nghĩa

Blobs chủ yếu được sử dụng trong tất cả các chương trình cơ sở dữ liệu. Nói chung, phần mềm cơ sở dữ liệu đối tượng nhị phân lớn có thể được chia thành hai loại. cấu trúc dữ liệu bán cấu trúc và dữ liệu cấu trúc phi cấu trúc. Tệp XML được phân loại là dữ liệu bán cấu trúc, trong khi định hình ảnh và phương tiện dữ liệu tiện ích được phân loại là kiểu dữ liệu có cấu trúc phân tích. Cả hai màu thường không được cơ sở dữ liệu giải thích. Vật thể lớn nhị phân (BLOB) là gì?

Đối tượng nhị phân lớn (BLOB) là một kiểu dữ liệu có thể lưu trữ các đối tượng hoặc dữ liệu nhị phân. LOB nhị phân được sử dụng trong cơ sở dữ liệu để lưu trữ dữ liệu nhị phân như hình ảnh, phương tiện tệp và mã thực thi. Hiểu các đối tượng nhị phân lớn (BLOB)

BOB được sử dụng trong tất cả các chương trình cơ sở dữ liệu. Thông thường, phần mềm cơ sở dữ liệu phân loại BLOB thành hai loại. cấu trúc dữ liệu bán cấu trúc và dữ liệu cấu trúc phi cấu trúc. Tệp XML được phân loại là dữ liệu bán cấu trúc, trong khi cấu hình ảnh và phương tiện được phân loại là kiểu dữ liệu phi cấu trúc. Cả hai màu này thường không được cơ sở dữ liệu giải thích. Các điều khoản liên quan

  • Đa phương tiện
  • Phần mềm cơ sở dữ liệu
  • nhị phân file
  • Đối tượng ký tự lớn (CLOB)
  • Hình ảnh do máy tính tạo ra (CGI)
  • Người xây dựng
  • Nhật thực
  • Tiếp chuyển
  • Hỗ trợ sự kiện tụng tự động (ALS)
  • bán sắc

Nguồn. Vật thể lớn nhị phân (BLOB) là gì?

Url blob là gì và tại sao nó được sử dụng?


348

Tôi có rất nhiều vấn đề với url blob

Tôi đã tìm kiếm video của    

duration:
8thẻ trên youtube và thấy rằng    
duration:
8nó giống như sau

src="blob:https://crap.crap"

Tôi đã mở url blob trong    

duration:
8video và nó đã thông báo lỗi cho tôi. Tôi không thể mở liên kết nhưng nó hoạt động với   
duration:
8thẻ. Làm thế nào nó có thể được?

Contra control

  • Url blob là gì?
  • Tại sao nó được sử dụng?
  • Tôi có thể tạo blog url của riêng mình trên máy chủ không?
  • If you have more information


– Nguồn Wakas Tahir



Câu trả lời


349

URL Blob (liên kết W3C, tên chính thức) hoặc đối tượng URL (liên kết MDN và tên phương thức) được sử dụng với các đối tượng Blob hoặc Tệp

src = “đốm màu. https. // tào lao. tào lao” Tôi đã mở url blob trong video src, nó bị lỗi và tôi không thể mở được, nhưng làm việc với thẻ src thì sao?

Chỉ có thể tạo các khối URL bên trong trình duyệt.

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
2 sẽ tạo một tham chiếu đặc biệt cho các đối tượng Blob hoặc File, sau đó các đối tượng này có thể được phân bổ
var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
3. Các URL này chỉ có thể được sử dụng bộ cục bộ trong một phiên bản duyệt và trong cùng một phiên bản (tức là trong suốt thời gian của trang / tài liệu)

Url blob là gì?
Tại sao nó được sử dụng?

Blob URL / URL là một giao thức giả cho phép các đối tượng Blob và Tệp được sử dụng làm URL nguồn cho những thứ như hình ảnh, liên kết tải xuống nhị phân, v. v

Ví dụ, bạn không thể xử lý byte dữ liệu thô của đối tượng hình ảnh vì nó sẽ không biết phải làm gì với nó. Nó yêu cầu hình ảnh ví dụ (là dữ liệu nhị phân) phải được tải xuống qua URL. Điều này được áp dụng cho bất kỳ điều gì yêu cầu URL là nguồn. Thay vì tải lên dữ liệu nhị phân, sau đó phân phát lại thông qua URL, tốt hơn là sử dụng một bước cục bộ bổ sung để có thể truy cập dữ liệu trực tiếp mà không cần thông qua máy chủ

Nó cũng là một sự thay thế tốt hơn cho Data-URI, các chuỗi được mã hóa thành Base-64. Vấn đề với Data-URI là mỗi char lấy hai byte trong JavaScript. Trên hết, 33% được thêm vào do mã hóa Base-64. Blobs là các mảng byte nhị phân thuần túy, không có bất kỳ chi phí đáng kể nào như Data-URI, điều này làm cho chúng nhanh hơn và nhỏ hơn để xử lý

Tôi có thể tạo url blob của riêng mình trên máy chủ không?

Không, URL Blob / URL object only can be used internal in browser. Bạn có thể tạo Blobs và nhận đối tượng Tệp thông tin qua Trình đọc tệp API, mặc dù BLOB chỉ có nghĩa là Đối tượng lớn nhị phân và được lưu trữ dưới dạng mảng byte. Một khách hàng có thể yêu cầu dữ liệu được gửi dưới dạng ArrayBuffer hoặc Blob. Máy chủ sẽ gửi dữ liệu dưới dạng dữ liệu nhị phân thuần túy. Cơ sở dữ liệu thường sử dụng Blob để mô tả các đối tượng nhị phân, và về bản chất chúng ta đang nói về cơ bản các mảng byte

if you have thì chi tiết bổ sung

Bạn cần đóng gói dữ liệu nhị phân dưới dạng đối tượng BLOB, sau đó sử dụng 

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
2 để tạo URL bộ cục bộ cho nó

________số 8

Lưu ý rằng 

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
5có thể có tiền tố trong trình duyệt webkit, vì vậy hãy sử dụng

duration:
0

— Bakudan
nguồn







10

Hàm Javascript này có nghĩa là hiển thị sự khác biệt giữa API tệp Blob và API Dữ liệu để tải xuống tệp JSON trong trình duyệt máy khách

duration:
1

Run đoạn mã mở rộng đoạn trích

Hàm được gọi là như 

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
6. Nó sẽ tạo ra một ByteStream ngay lập tức trình duyệt được duyệt và sẽ tải xuống tệp được tạo trực tiếp bằng tệp API 
var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
7

Trong 

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
8đó, có thể thấy kết quả tương ứng được thông qua_______59 phần tử cộng với dữ liệu API, nhưng điều này có một số giới hạn mà API Blob không có. — loretoparisi
nguồn



3

Url blob là gì?

BLOB chỉ là byte chuỗi. Trình duyệt nhận ra nó là byte luồng. It is used to get stream byte from source

Một đối tượng Blob đại diện cho một đối tượng giống như tệp của dữ liệu thô, không thay đổi. Các đốm màu đại diện cho dữ liệu không nhất thiết phải ở định dạng JavaScript gốc. Giao diện Tệp dựa trên Blob, kế thừa chức năng blob và mở rộng nó để hỗ trợ các tệp trên hệ thống của người dùng

Tôi có thể tạo url blob của riêng mình trên máy chủ không?

Có, bạn có thể có các cách máy chủ để làm như vậy, ví dụ: hãy thử http. //php. net/thủ công/vi/chức năng. ibase-blob-echo. php

Đọc thêm về

  • https. // nhà phát triển. mozilla. org/pl/docs/Web/API/Blob
  • http. //www. w3. org/TR/FileAPI/#dfn-Blob
  • https. // url. thông số kỹ thuật. cái gì. tổ chức/#urls

— Robert
nguồn






2

Tôi đã sửa đổi giải pháp làm việc để xử lý cả hai trường hợp. khi video được tải lên và khi hình ảnh được tải lên. hy vọng nó sẽ giúp một số

HTML

duration:

Javascript

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};

url jsFiddle

https. //jsfiddle. net/PratapDessai/0sp3b159/— Dapai
nguồn

Đối tượng lớn nhị phân (BLOB)

Định nghĩa của đối tượng lớn nhị phân (BLOB) là gì?

Đối tượng lớn nhị phân (BLOB) là đối tượng lớn nhị phân (BLOB). Đây là nghĩa tiếng Việt của thuật ngữ Đối tượng lớn nhị phân (BLOB) – một thuật ngữ thuộc nhóm Thuật ngữ công nghệ – Công nghệ thông tin. yếu tố đánh giá. 5/10

Một đối tượng lớn nhị phân (BLOB) là một kiểu dữ liệu có thể lưu trữ các đối tượng hoặc dữ liệu nhị phân. Các đối tượng lớn nhị phân được sử dụng trong cơ sở dữ liệu để lưu trữ dữ liệu nhị phân như hình ảnh, tệp đa phương tiện và mã phần mềm thực thi

Xem thêm. AZ. thuật ngữ công nghệ

Giải thích ý nghĩa

Các đối tượng nhị phân lớn chủ yếu được sử dụng trong tất cả các phần mềm cơ sở dữ liệu. Nói chung, phần mềm cơ sở dữ liệu nhị phân đối tượng lớn có thể được phân thành hai loại. dữ liệu bán cấu trúc và dữ liệu phi cấu trúc. Các tệp XML được phân loại là dữ liệu bán cấu trúc, trong khi dữ liệu hình ảnh và đa phương tiện là các loại dữ liệu có cấu trúc. Cả hai đốm màu thường không thể hiểu được bởi cơ sở dữ liệu. Đối tượng lớn nhị phân (BLOB) là gì?

Một đối tượng lớn nhị phân (BLOB) là một kiểu dữ liệu có thể lưu trữ các đối tượng hoặc dữ liệu nhị phân. Các đối tượng lớn nhị phân được sử dụng trong cơ sở dữ liệu để lưu trữ dữ liệu nhị phân như hình ảnh, tệp đa phương tiện và mã phần mềm thực thi. Hiểu đối tượng lớn nhị phân (BLOB)

Các đối tượng lớn nhị phân là ưu việt trong tất cả các phần mềm cơ sở dữ liệu. Nói chung, phần mềm cơ sở dữ liệu phân loại các đối tượng lớn nhị phân thành hai loại. dữ liệu bán cấu trúc và dữ liệu phi cấu trúc. Các tệp XML được phân loại là dữ liệu bán cấu trúc, trong khi hình ảnh và dữ liệu đa phương tiện là các loại dữ liệu phi cấu trúc. Cả hai BLOB này thường không thể hiểu được bởi cơ sở dữ liệu. thuật ngữ liên quan

  • đa phương tiện
  • Phần mềm cơ sở dữ liệu
  • Tệp nhị phân
  • Đối tượng lớn ký tự (CLOB)
  • Hình ảnh do máy tính tạo ra (CGI)
  • Người xây dựng
  • nhật thực
  • Tạm thời
  • Hỗ trợ kiện tụng tự động (ALS)
  • bán sắc

Nguồn. Đối tượng lớn nhị phân (BLOB) là gì?

URL blob là gì và tại sao nó được sử dụng?


348

Tôi đang gặp rất nhiều vấn đề với URL blob

Tôi đã tìm kiếm 

duration:
8một thẻ video trên YouTube và tôi thấy rằng video đó 
duration:
8giống như vậy

src="blob:https://crap.crap"

Tôi đã mở URL blob trong 

duration:
8video mà nó báo lỗi. Tôi không thể mở liên kết, nhưng nó đã hoạt động với 
duration:
8thẻ. Sao có thể như thế được?

Request

  • URL blob là gì?
  • Tại sao nó được sử dụng?
  • Tôi có thể tạo blob URL của riêng mình trên máy chủ không?
  • Nếu bạn có bất kỳ chi tiết bổ sung nào

— Waqas Tahir
nguồn



Câu trả lời


349

URL Blob (ref W3C , tên chính thức) hoặc đối tượng URL (ref. MDN và tên phương thức) được sử dụng với các đối tượng Blob hoặc Tệp

src = “đốm màu. https. // tào lao. tào lao ” Tôi đã mở url blob trong src của video, nó bị lỗi và tôi không thể mở nhưng đang làm việc với thẻ src thì sao?

URL Blob chỉ có thể được tạo bởi trình duyệt nội bộ.

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
2 sẽ tạo một tham chiếu đặc biệt cho các đối tượng Blob hoặc File mà sau này có thể được phát hành theo cách sử dụng 
var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
3. Các URL này chỉ có thể được sử dụng bộ cục bộ trong phiên bản duy nhất của trình duyệt và trong cùng một phiên bản (tức là tuổi thọ của trang / tài liệu)

Url blob là gì?
Tại sao nó được sử dụng?

URL / URL đối tượng Blob là một giao thức giả để cho phép các đối tượng Blob và Tệp được sử dụng làm URL nguồn cho những thứ như hình ảnh, liên kết tải xuống cho dữ liệu nhị phân, v. v

Ví dụ, bạn không thể xử lý byte dữ liệu thô của đối tượng hình ảnh vì nó sẽ không biết phải làm gì với nó. Nó yêu cầu hình ảnh ví dụ (là dữ liệu nhị phân) phải được tải xuống qua URL. Điều này được áp dụng cho bất kỳ điều gì yêu cầu URL là nguồn. Thay vì tải lên dữ liệu nhị phân, sau đó phân phát lại thông qua URL, tốt hơn là sử dụng một bước cục bộ bổ sung để có thể truy cập dữ liệu trực tiếp mà không cần thông qua máy chủ

Nó cũng là một sự thay thế tốt hơn cho Data-URI, các chuỗi được mã hóa thành Base-64. Vấn đề với Data-URI là mỗi char lấy hai byte trong JavaScript. Trên hết, 33% được thêm vào do mã hóa Base-64. Blobs là các mảng byte nhị phân thuần túy, không có bất kỳ chi phí đáng kể nào như Data-URI, điều này làm cho chúng nhanh hơn và nhỏ hơn để xử lý

Tôi có thể tạo url blob của riêng mình trên máy chủ không?

Không, URL Blob / URL object only can be used internal in browser. Bạn có thể tạo Blobs và nhận đối tượng Tệp thông tin qua Trình đọc tệp API, mặc dù BLOB chỉ có nghĩa là Đối tượng lớn nhị phân và được lưu trữ dưới dạng mảng byte. Một khách hàng có thể yêu cầu dữ liệu được gửi dưới dạng ArrayBuffer hoặc Blob. Máy chủ sẽ gửi dữ liệu dưới dạng dữ liệu nhị phân thuần túy. Cơ sở dữ liệu thường sử dụng Blob để mô tả các đối tượng nhị phân, và về bản chất chúng ta đang nói về cơ bản các mảng byte

if you have thì chi tiết bổ sung

Bạn cần đóng gói dữ liệu nhị phân dưới dạng đối tượng BLOB, sau đó sử dụng 

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
2 để tạo URL bộ cục bộ cho nó

________số 8

Lưu ý rằng 

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
5có thể có tiền tố trong trình duyệt webkit, vì vậy hãy sử dụng

duration:
0

— Bakudan
nguồn







10

Hàm Javascript này có nghĩa là hiển thị sự khác biệt giữa API tệp Blob và API Dữ liệu để tải xuống tệp JSON trong trình duyệt máy khách

duration:
1

Run đoạn mã mở rộng đoạn trích

Hàm được gọi là như 

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
6. Nó sẽ tạo ra một ByteStream ngay lập tức trình duyệt được duyệt và sẽ tải xuống tệp được tạo trực tiếp bằng tệp API 
var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
7

Trong 

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
8đó, có thể thấy kết quả tương ứng được thông qua_______59 phần tử cộng với dữ liệu API, nhưng điều này có một số giới hạn mà API Blob không có. — loretoparisi
nguồn



3

Url blob là gì?

BLOB chỉ là byte chuỗi. Trình duyệt nhận ra nó là byte luồng. It is used to get stream byte from source

Объект Blob представляет собой файловый объект необработанных неизменяемых данных. BLOB-объекты представляют данные, которые явно не в родном формате JavaScript. Интерфейс File основан на Blob, который наследует функциональные возможности больших двоичных объектов и расширяет их для поддержки файлов в системе пользователя

Tại sao bạn không thể truy cập vào trang web của mình?

Да, у вас могут быть серверные способы сделать это, например, попробуйте http. //php. net/thủ công/vi/chức năng. ibase-blob-echo. php

Подробнее о

  • https. // nhà phát triển. mozilla. org/pl/docs/Web/API/Blob
  • http. //www. w3. org/TR/FileAPI/#dfn-Blob
  • https. // url. thông số kỹ thuật. cái gì. tổ chức/#urls

— Роберт
источник






2

З

HTML

duration:

Javascript

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};

URL-aдрес jsFiddle

https. //jsfiddle. net/PratapDessai/0sp3b159/ — источник Дапай

Двоичный большой объект (BLOB)

Làm thế nào để bạn có thể phát trực tuyến (BLOB)?

Большой двоичный объект (BLOB) — это большой двоичный объект (BLOB). Э. Рейтинг фактора. 5/10

Двоичный большой объект (BLOB) — это тип данных, который может хранить двоичные объекы или неан. Двоичные большие объекты используются в базах данных для хранения двоичных данных, таких как изображения, мультимедийные файлы и исполняемый программный код

Смотрите также. АЗ. технологическая терминология

Объясните значение

Большие двоичные объекты в основном используются во всех программах баз данных. В р л. полуструктурированные данные và неструктурированные данные. XML-й. Оба больших двоичных объекта обычно не интерпретируются базой данных. Bạn có biết thế giới của mình là BLOB không?

Двоичный большой объект (BLOB) — это тип данных, который может хранить двоичные объекы или неан. Двоичные большие объекты используются в базах данных для хранения двоичных данных, таких как изображения, мультимедийные файлы и исполняемый программный код. Общие сведения о больших двоичных объектах (BLOB)

Двоичные большие объекты используются во всех программах баз данных. Как правило, программное обеспечение базы данных классифицирует большие двоичдые объектыаиа наиа. частично структурированные данные và неструктурированные данные. XML-файлы классифицируются как частично структурированные данные, тогда как изображения и мультимедийные данные относятся к неструктурированным типам данных. Оба этих больших двоичных объекта обычно не интерпретируются базой данных. Связанные термины

  • Мультимедиа
  • Программное обеспечение базы данных
  • Двоичные файлы
  • Символьный большой объект (CLOB)
  • Kỹ xảo điện ảnh (CGI)
  • Конструктор
  • Затмение
  • Переходный
  • Bệnh ALS (ALS)
  • Полутона

Источник. bạn có biết thế giới của mình (BLOB) không?

Bạn có biết URL-aдрес большого двоичного объекта và почему он используется?


348

У меня много проблем с URL-адресами больших двоичных объектов

Я искал  

duration:
8тег видео trên YouTube và обнаружил, что  
duration:
8он выглядит так

src="blob:https://crap.crap"

Я открыл URL-адрес большого двоичного объекта в  

duration:
8видео, и он выдал мне ошибку. Я не мог открыть ссылку, но она работала с  
duration:
8тегом. Bạn có muốn làm gì không?

Запрос

  • Bạn có biết URL-адрес большого двоичного объекта không?
  • Bạn có muốn làm gì không?
  • Tại sao bạn không thể truy cập vào trang web của mình?
  • Если у вас есть дополнительная информация


– Источник Вакас Тахир



Отвечать


349

Url-адрес blob-о

src=”đốm màu. https. // tào lao. tào lao о о

URL-адреса больших двоичных объектов могут создаваться только внутри браузера. 3 3. Ur. e. в течение срока действия страницы/документа)

Что такое URL-адрес BLOB-объекта?
Почему это используется?

URL/URL объекта Blob — это псевдопротокол, позволяющий использовать объекты Blob и File в качестве источников URL для таких вещей, как изображения, ссылки для скачивания двоичных данных и т. д

Ví dụ, bạn không thể xử lý byte dữ liệu thô của đối tượng hình ảnh vì nó sẽ không biết phải làm gì với nó. Nó yêu cầu hình ảnh ví dụ (là dữ liệu nhị phân) phải được tải xuống qua URL. Điều này được áp dụng cho bất kỳ điều gì yêu cầu URL là nguồn. Thay vì tải lên dữ liệu nhị phân, sau đó phân phát lại thông qua URL, tốt hơn là sử dụng một bước cục bộ bổ sung để có thể truy cập dữ liệu trực tiếp mà không cần thông qua máy chủ

Nó cũng là một sự thay thế tốt hơn cho Data-URI, các chuỗi được mã hóa thành Base-64. Vấn đề với Data-URI là mỗi char lấy hai byte trong JavaScript. Trên hết, 33% được thêm vào do mã hóa Base-64. Blobs là các mảng byte nhị phân thuần túy, không có bất kỳ chi phí đáng kể nào như Data-URI, điều này làm cho chúng nhanh hơn và nhỏ hơn để xử lý

Tôi có thể tạo url blob của riêng mình trên máy chủ không?

Không, URL Blob / URL object only can be used internal in browser. Bạn có thể tạo Blobs và nhận đối tượng Tệp thông tin qua Trình đọc tệp API, mặc dù BLOB chỉ có nghĩa là Đối tượng lớn nhị phân và được lưu trữ dưới dạng mảng byte. Một khách hàng có thể yêu cầu dữ liệu được gửi dưới dạng ArrayBuffer hoặc Blob. Máy chủ sẽ gửi dữ liệu dưới dạng dữ liệu nhị phân thuần túy. Cơ sở dữ liệu thường sử dụng Blob để mô tả các đối tượng nhị phân, và về bản chất chúng ta đang nói về cơ bản các mảng byte

if you have thì chi tiết bổ sung

Bạn cần đóng gói dữ liệu nhị phân dưới dạng đối tượng BLOB, sau đó sử dụng 

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
2 để tạo URL bộ cục bộ cho nó

________số 8

Lưu ý rằng 

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
5có thể có tiền tố trong trình duyệt webkit, vì vậy hãy sử dụng

duration:
0

— Bakudan
nguồn







10

Hàm Javascript này có nghĩa là hiển thị sự khác biệt giữa API tệp Blob và API Dữ liệu để tải xuống tệp JSON trong trình duyệt máy khách

duration:
1

Run đoạn mã mở rộng đoạn trích

Hàm được gọi là như 

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
6. Nó sẽ tạo ra một ByteStream ngay lập tức trình duyệt được duyệt và sẽ tải xuống tệp được tạo trực tiếp bằng tệp API 
var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
7

Trong 

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
8đó, có thể thấy kết quả tương ứng được thông qua_______59 phần tử cộng với dữ liệu API, nhưng điều này có một số giới hạn mà API Blob không có. — loretoparisi
nguồn



3

Url blob là gì?

BLOB chỉ là byte chuỗi. Trình duyệt nhận ra nó là byte luồng. It is used to get stream byte from source

Một đối tượng Blob đại diện cho một đối tượng giống như tệp của dữ liệu thô, không thay đổi. Các đốm màu đại diện cho dữ liệu không nhất thiết phải ở định dạng JavaScript gốc. Giao diện Tệp dựa trên Blob, kế thừa chức năng blob và mở rộng nó để hỗ trợ các tệp trên hệ thống của người dùng

Tôi có thể tạo url blob của riêng mình trên máy chủ không?

Có, bạn có thể có các cách máy chủ để làm như vậy, ví dụ: hãy thử http. //php. net/thủ công/vi/chức năng. ibase-blob-echo. php

Đọc thêm về

  • https. // nhà phát triển. mozilla. org/pl/docs/Web/API/Blob
  • http. //www. w3. org/TR/FileAPI/#dfn-Blob
  • https. // url. thông số kỹ thuật. cái gì. tổ chức/#urls

— Robert
nguồn






2

Tôi đã sửa đổi giải pháp làm việc để xử lý cả hai trường hợp. khi video được tải lên và khi hình ảnh được tải lên. hy vọng nó sẽ giúp một số

HTML

duration:

Javascript

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};

url jsFiddle

https. //jsfiddle. net/PratapDessai/0sp3b159/— Dapai
nguồn

Đối tượng lớn nhị phân (BLOB)

Định nghĩa của đối tượng lớn nhị phân (BLOB) là gì?

Đối tượng lớn nhị phân (BLOB) là đối tượng lớn nhị phân (BLOB). Đây là nghĩa tiếng Việt của thuật ngữ Đối tượng lớn nhị phân (BLOB) – một thuật ngữ thuộc nhóm Thuật ngữ công nghệ – Công nghệ thông tin. yếu tố đánh giá. 5/10

Một đối tượng lớn nhị phân (BLOB) là một kiểu dữ liệu có thể lưu trữ các đối tượng hoặc dữ liệu nhị phân. Các đối tượng lớn nhị phân được sử dụng trong cơ sở dữ liệu để lưu trữ dữ liệu nhị phân như hình ảnh, tệp đa phương tiện và mã phần mềm thực thi

Xem thêm. AZ. thuật ngữ công nghệ

Giải thích ý nghĩa

Các đối tượng nhị phân lớn chủ yếu được sử dụng trong tất cả các phần mềm cơ sở dữ liệu. Nói chung, phần mềm cơ sở dữ liệu nhị phân đối tượng lớn có thể được phân thành hai loại. dữ liệu bán cấu trúc và dữ liệu phi cấu trúc. Các tệp XML được phân loại là dữ liệu bán cấu trúc, trong khi dữ liệu hình ảnh và đa phương tiện là các loại dữ liệu có cấu trúc. Cả hai đốm màu thường không thể hiểu được bởi cơ sở dữ liệu. Đối tượng lớn nhị phân (BLOB) là gì?

Một đối tượng lớn nhị phân (BLOB) là một kiểu dữ liệu có thể lưu trữ các đối tượng hoặc dữ liệu nhị phân. Các đối tượng lớn nhị phân được sử dụng trong cơ sở dữ liệu để lưu trữ dữ liệu nhị phân như hình ảnh, tệp đa phương tiện và mã phần mềm thực thi. Hiểu đối tượng lớn nhị phân (BLOB)

Các đối tượng lớn nhị phân là ưu việt trong tất cả các phần mềm cơ sở dữ liệu. Nói chung, phần mềm cơ sở dữ liệu phân loại các đối tượng lớn nhị phân thành hai loại. dữ liệu bán cấu trúc và dữ liệu phi cấu trúc. Các tệp XML được phân loại là dữ liệu bán cấu trúc, trong khi hình ảnh và dữ liệu đa phương tiện là các loại dữ liệu phi cấu trúc. Cả hai BLOB này thường không thể hiểu được bởi cơ sở dữ liệu. thuật ngữ liên quan

  • đa phương tiện
  • Phần mềm cơ sở dữ liệu
  • Tệp nhị phân
  • Đối tượng lớn ký tự (CLOB)
  • Hình ảnh do máy tính tạo ra (CGI)
  • Người xây dựng
  • nhật thực
  • Tạm thời
  • Hỗ trợ kiện tụng tự động (ALS)
  • bán sắc

Nguồn. Đối tượng lớn nhị phân (BLOB) là gì?

URL blob là gì và tại sao nó được sử dụng?


348

Tôi đang gặp rất nhiều vấn đề với URL blob

Tôi đã tìm kiếm 

duration:
8một thẻ video trên YouTube và tôi thấy rằng video đó 
duration:
8giống như vậy

src="blob:https://crap.crap"

Tôi đã mở URL blob trong 

duration:
8video mà nó báo lỗi. Tôi không thể mở liên kết, nhưng nó đã hoạt động với 
duration:
8thẻ. Sao có thể như thế được?

Request

  • URL blob là gì?
  • Tại sao nó được sử dụng?
  • Tôi có thể tạo blob URL của riêng mình trên máy chủ không?
  • Nếu bạn có bất kỳ chi tiết bổ sung nào

— Waqas Tahir
nguồn



Câu trả lời


349

URL Blob (ref W3C , tên chính thức) hoặc đối tượng URL (ref. MDN và tên phương thức) được sử dụng với các đối tượng Blob hoặc Tệp

src = “đốm màu. https. // tào lao. tào lao ” Tôi đã mở url blob trong src của video, nó bị lỗi và tôi không thể mở nhưng đang làm việc với thẻ src thì sao?

URL Blob chỉ có thể được tạo bởi trình duyệt nội bộ.

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
2 sẽ tạo một tham chiếu đặc biệt cho các đối tượng Blob hoặc File mà sau này có thể được phát hành theo cách sử dụng 
var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
3. Các URL này chỉ có thể được sử dụng bộ cục bộ trong phiên bản duy nhất của trình duyệt và trong cùng một phiên bản (tức là tuổi thọ của trang / tài liệu)

Url blob là gì?
Tại sao nó được sử dụng?

URL / URL đối tượng Blob là một giao thức giả để cho phép các đối tượng Blob và Tệp được sử dụng làm URL nguồn cho những thứ như hình ảnh, liên kết tải xuống cho dữ liệu nhị phân, v. v

Ví dụ, bạn không thể xử lý byte dữ liệu thô của đối tượng hình ảnh vì nó sẽ không biết phải làm gì với nó. Nó yêu cầu hình ảnh ví dụ (là dữ liệu nhị phân) phải được tải xuống qua URL. Điều này được áp dụng cho bất kỳ điều gì yêu cầu URL là nguồn. Thay vì tải lên dữ liệu nhị phân, sau đó phân phát lại thông qua URL, tốt hơn là sử dụng một bước cục bộ bổ sung để có thể truy cập dữ liệu trực tiếp mà không cần thông qua máy chủ

Nó cũng là một sự thay thế tốt hơn cho Data-URI, các chuỗi được mã hóa thành Base-64. Vấn đề với Data-URI là mỗi char lấy hai byte trong JavaScript. Trên hết, 33% được thêm vào do mã hóa Base-64. Blobs là các mảng byte nhị phân thuần túy, không có bất kỳ chi phí đáng kể nào như Data-URI, điều này làm cho chúng nhanh hơn và nhỏ hơn để xử lý

Tôi có thể tạo url blob của riêng mình trên máy chủ không?

Không, URL Blob / URL object only can be used internal in browser. Bạn có thể tạo Blobs và nhận đối tượng Tệp thông tin qua Trình đọc tệp API, mặc dù BLOB chỉ có nghĩa là Đối tượng lớn nhị phân và được lưu trữ dưới dạng mảng byte. Một khách hàng có thể yêu cầu dữ liệu được gửi dưới dạng ArrayBuffer hoặc Blob. Máy chủ sẽ gửi dữ liệu dưới dạng dữ liệu nhị phân thuần túy. Cơ sở dữ liệu thường sử dụng Blob để mô tả các đối tượng nhị phân, và về bản chất chúng ta đang nói về cơ bản các mảng byte

if you have thì chi tiết bổ sung

Bạn cần đóng gói dữ liệu nhị phân dưới dạng đối tượng BLOB, sau đó sử dụng 

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
2 để tạo URL bộ cục bộ cho nó

________số 8

Lưu ý rằng 

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
5có thể có tiền tố trong trình duyệt webkit, vì vậy hãy sử dụng

duration:
0

— Bakudan
nguồn







10

Hàm Javascript này có nghĩa là hiển thị sự khác biệt giữa API tệp Blob và API Dữ liệu để tải xuống tệp JSON trong trình duyệt máy khách

duration:
1

Run đoạn mã mở rộng đoạn trích

Hàm được gọi là như 

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
6. Nó sẽ tạo ra một ByteStream ngay lập tức trình duyệt được duyệt và sẽ tải xuống tệp được tạo trực tiếp bằng tệp API 
var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
7

Trong 

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};
8đó, có thể thấy kết quả tương ứng được thông qua_______59 phần tử cộng với dữ liệu API, nhưng điều này có một số giới hạn mà API Blob không có. — loretoparisi
nguồn



3

Url blob là gì?

BLOB chỉ là byte chuỗi. Trình duyệt nhận ra nó là byte luồng. It is used to get stream byte from source

Объект Blob представляет собой файловый объект необработанных неизменяемых данных. BLOB-объекты представляют данные, которые явно не в родном формате JavaScript. Интерфейс File основан на Blob, который наследует функциональные возможности больших двоичных объектов и расширяет их для поддержки файлов в системе пользователя

Tại sao bạn không thể truy cập vào trang web của mình?

Да, у вас могут быть серверные способы сделать это, например, попробуйте http. //php. net/thủ công/vi/chức năng. ibase-blob-echo. php

Подробнее о

  • https. // nhà phát triển. mozilla. org/pl/docs/Web/API/Blob
  • http. //www. w3. org/TR/FileAPI/#dfn-Blob
  • https. // url. thông số kỹ thuật. cái gì. tổ chức/#urls

— Роберт
источник






2

З

HTML

duration:

Javascript

var fileEl = document.querySelector("input");fileEl.onchange = function(e) {    var file = e.target.files[0]; // selected file    if (!file) {        console.log("nothing here");        return;    }    console.log(file);    console.log('file.size-' + file.size);    console.log('file.type-' + file.type);    console.log('file.acutalName-' + file.name);    let start = performance.now();    var mime = file.type, // store mime for later        rd = new FileReader(); // create a FileReader    if (/video/.test(mime)) {        rd.onload = function(e) { // when file has read:            var blob = new Blob([e.target.result], {                    type: mime                }), // create a blob of buffer                url = (URL || webkitURL).createObjectURL(blob), // create o-URL of blob                video = document.createElement("video"); // create video element            //console.log(blob);            video.preload = "metadata"; // preload setting            video.addEventListener("loadedmetadata", function() { // when enough data loads                console.log('video.duration-' + video.duration);                console.log('video.videoHeight-' + video.videoHeight);                console.log('video.videoWidth-' + video.videoWidth);                //document.querySelector("div")                //  .innerHTML = "Duration: " + video.duration + "s" + " 
Height: " + video.videoHeight; // show duration (URL || webkitURL).revokeObjectURL(url); // clean up console.log(start - performance.now()); // .. continue from here .. }); video.src = url; // start video load }; } else if (/image/.test(mime)) { rd.onload = function(e) { var blob = new Blob([e.target.result], { type: mime }), url = URL.createObjectURL(blob), img = new Image(); img.onload = function() { console.log('iamge'); console.dir('this.height-' + this.height); console.dir('this.width-' + this.width); URL.revokeObjectURL(this.src); // clean-up memory console.log(start - performance.now()); // add image to DOM } img.src = url; }; } var chunk = file.slice(0, 1024 * 1024 * 10); // .5MB rd.readAsArrayBuffer(chunk); // read file object};

Url JsFiddle

https. //jsfiddle. net/PratapDessai/0sp3b159/ –  Nguồn  Dapai



Video Blob is what. Tất tần tật về blob

Cảm ơn các bạn đã theo dõi bài viết Blob là gì. Tất tần tật về blob. 123 DocX hi vọng đã mang đến thông tin hữu ích cho bạn. Xem thêm các bài viết cùng danh mục Hỏi đáp. Nếu thấy hay hãy share bài viết này cho nhiều người được biết. 123 DocX chúc bạn ngày vui vẻ