Handling dynamic headers from transformFile

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

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

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
react, typescript
Lĩnh vực
frontend

Hướng nghiên cứu

Bắt đầu trong src/AjaxUploader.jsx, tại các headers được truyền vào yêu cầu upload, và xem xét luồng transformFile được mô tả trong issue. Cập nhật mục headers trong README cùng với hành vi này. Hoàn tất khi headers có thể được cung cấp dưới dạng một hàm nhận file đã được transform, trong khi headers dạng object vẫn tiếp tục hoạt động.

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

Mô tả

Hi there!

We have a situation where we use rc-upload in the following manner:

  • User selects file on file system
  • We use transformFile to encrypt the contents of that file on the browser
  • The encryption generates additional metadata that we want to pass as headers
  • This metadata is not available until transformFile is completed.

It would be great if headers could also be a function that takes in the result of transformFile and returns the headers.

I tried to make a PR for this but it was not possible bc of permissions.

The changes to do this are pretty quick:
in AjaxUploader.tsx

change

headers: props.headers,

to

headers: typeof props.headers === 'function' ? props.headers(transformedFile) : props.headers,

and also update the README comment to me

|headers| object/function(blob) | {} | http headers to post, available in modern browsers. Can be a function that takes in the result of transformFile |

Ngôn ngữ chính
TypeScript
Star
804
Fork
323
Merge trung bình
12 phút
Pull request đã merge (30 ngày)
1

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

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

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.

Issue khác của react-component/upload

Tất cả issue của react-component/upload

Issue tương tự

Thêm issue về TypeScript

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.