Consider adding `blob.dataUrl()` method, or some other analogue to `readAsDataURL`
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 30/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript
Hướng nghiên cứu
Issue không xác định tệp nào trong repository hoặc test nào. Hãy bắt đầu bằng việc xem xét các phương thức arrayBuffer() và text() hiện có của Blob cùng với các đề xuất binary-encoding và ArrayBuffer base64 được liên kết, sau đó xác định xem đã có định hướng được xác định cho một API data URL dựa trên promise hay chưa. Điều kiện hoàn thành là có một thiết kế API đã được thống nhất, chứ không chỉ là một chỉnh sửa cục bộ.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Obviously data URLs and base64 in general should be avoided where possible, but unfortunately developers are often interacting with systems/libraries/APIs outside their control, and, practically, readAsDataURL is used a lot.
In fact, readAsDataURL is used about as much as readAsText and readAsArrayBuffer combined:
- readAsDataURL: https://github.com/search?l=JavaScript&q=readAsDataURL&type=Code (1.6 million hits)
- readAsText: https://github.com/search?l=JavaScript&q=readAsText&type=Code (770k hits)
- readAsArrayBuffer: https://github.com/search?l=JavaScript&q=readAsArrayBuffer&type=Code (830k hits)
The blob.arrayBuffer() and blob.text() methods are delightful to use compared to previous methods, but for data URLs / base64 we're stuck with:
let file = ...;
let dataUrl = await new Promise((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => resolve(reader.result);
reader.onerror = (e) => reject(e);
});
which is the opposite of delightful. This is one of those cases where I'm "embarrassed" by how convoluted a simple task is in JS when helping someone who is new to JS.
There are a couple of proposals that are related to this issue:
- https://github.com/lucacasonato/proposal-binary-encoding
- https://github.com/tc39/proposal-arraybuffer-base64
That said, I really like promise-based blob.methodName() approach, and I'm hoping that we'll eventually get something like that for data URLs.
- Ngôn ngữ chính
- HTML
- Star
- 118
- Fork
- 52
- Merge trung bình
- 9 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 1
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của w3c/FileAPI
-
TPAC 2026 Status Report Đang mởTPAC2026
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Broken references in File API Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 62/100
-
Add accessibility section Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
use-agent-os/agent-os#3276 ·
-
good first issue refactor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
[6.x]: "Cannot use object of type stdClass as array" loading Users index (regression of #19182) Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
-
area/sessions comp/agent P2 tool/skills type/perf
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
NousResearch/hermes-agent#117788 ·