w3c / w3c/FileAPI

Allow `createObjectURL` to retain filename from `File` (and similar) objects

Đang mở
#203 7 bình luận 3 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

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

Mô tả

What problem are you trying to solve?

We have a datastore that requires authentication to retrieve files (e.g. PDF, CSV, ZIP, PNG, or some Office suite file format) -- it has a file name, a content type, and data. We'd like to allow users to click a link (or button/...) and have the "file" corresponding to that data (which we currently retrieve in a Blob) open in their browser (or download depending on how the browser is feeling) and if at some point the browser decides to save the file (e.g. because the user asks to save a file, or because it doesn't have an internal handler) then we'd like it to favor our proposed filename instead of a blob id.

What solutions exist today?
  1. We can construct a Blob or a File w/ a Blob and call createObjectURL with it.
  2. We can create an anchor a with a#download with the href set the the url from createObjectURL such that users can click the anchor to get our suggested filename.
  3. We can add an iframe containing our blob url

Fwiw, Microsoft had an msSaveBlob which included a defaultName field...

How would you solve it?

Change the specification for createObjectURL so that for objects that have a name (e.g. File), browsers should prefer that name over the blob when saving.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách đọc đặc tả File API xoay quanh điểm vào createObjectURL và các định nghĩa của File, Blob và object URLs. Xác định tên tệp được đề xuất nên tương tác như thế nào với hành vi lưu, sau đó cập nhật đặc tả để định nghĩa tùy chọn đó và thêm hoặc điều chỉnh phạm vi bao phủ tính tương thích nếu đặc tả xác định một vị trí kiểm thử liên quan.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
html
Lĩnh vực
api, web-dev
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.