Consider Blob.fromStream (returns a Promise<Blob>)
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
- 25/100
Hướng nghiên cứu
Issue không nêu tên tệp nào trong repository hoặc test nào. Hãy bắt đầu bằng cách so sánh các API Blob, ReadableStream và Response(...).blob() hiện tại được mô tả ở đây; để hoàn tất, cần có thiết kế API được thống nhất cho Blob.fromStream, các tùy chọn của nó và vấn đề liên quan đến File, sau đó là các đặc tả và test tuân thủ áp dụng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I'm filing this as a tracking issue, although I don't think it's particularly urgent. But maybe web developers have run into this more, in which case hearing from them would be great.
Anyway, right now, to convert a ReadableStream to a Blob, you have to do
const blob = await new Response(stream).blob();
which is pretty silly. Just as blob.stream() was added to avoid the silly new Request(blob).body pattern, perhaps we should consider adding a promise-returning Blob.fromStream() so you could do
const blob = await Blob.fromStream(stream);
There is a bigger savings if we add an options parameter:
const blob1 = new Blob([await new Response(stream).blob()], options);
const blob2 = Blob.fromStream(stream, options);
Points to consider:
- We could instead make this
stream.toBlob(), but I feel the layering of keeping streams ignorant of blobs is a bit cleaner. - We may not want to introduce this because it's better if people avoid using blobs? (Or is it just blob URLs that we dislike?)
- If someone wanted a
File, we could either addFile.fromStream(stream, fileName, options)or we could have people donew File([Blob.fromStream(stream)], fileName, options). ProbablyFile.fromStream()is nicer. - This does not allow creating a blob that represents an "in progress" stream, which I've heard people have wanted in order to have self-referential blobs. That would require new concepts and infrastructure. This proposal is basically just exposing existing infrastructure in a more straightforward way.
- 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ự
-
bug priority:normal ready-for-dev
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
OpenHands/extensions#626 · 1 bình luận ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
avniproject/avni-client#2135 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ 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 ·