Ưu đãi trong tuần: Nhập mã UD50 giảm 50k cho đơn từ 300k!
Trang chủ
Menu

DIY Code & Transfer Files using WebRTC 2026

Tự Code & Truyền File Bằng WebRTC 2026

Tự Code & Truyền File Bằng WebRTC 2026

Xây dựng ứng dụng truyền file thời gian thực bằng WebRTC data channels. Hiểu về ArrayBuffers, Blobs, Buffers, Chunks và nhiều hơn nữa!

4.9
(18 đánh giá)
237 học viên
Giảng viên
Clyde Matthew
Phụ đề Việt chất lượng cao Phụ đề tiếng Anh Bán chạy Đánh giá cao
50.000đ 399.000đ -87%
✓ Xem giỏ hàng và thanh toán
Bao gồm phụ đề tiếng Việt, tiếng Anh
8.5 giờ video
117 bài giảng
8 bài quiz
Truy cập vĩnh viễn
Học trên mọi thiết bị
Cập nhật: 31/05/2026

Bạn sẽ học được gì

Học cách gửi file bằng WebRTC như một cao thủ thực thụ
Nắm vững File API, FileReader API, Streams API và hơn thế nữa!
Làm chủ các khái niệm về buffering và send queues
Làm việc với ArrayBuffers, Blobs và chunks để gửi dữ liệu file
Phân biệt ArrayBuffer và Blobs
Học các phương pháp khác nhau để đọc, chia nhỏ và gửi file qua WebRTC
Tìm hiểu về thuộc tính bufferedAmount và bufferedAmountLowThreshold
Thiết lập kết nối WebRTC để truyền file qua data channel
Hiểu tại sao FileReader API không phù hợp với file lớn
Hiểu về nén dữ liệu và sử dụng Pako để nén dữ liệu file
Học vì sao metadata lại quan trọng để bên nhận hiểu và tái tạo dữ liệu nhị phân của file
Xây dựng kết nối WebRTC từ đầu, bao gồm STUN, ICE, Offers và Answers
Học cách nén dữ liệu nhị phân của file để gửi nhanh hơn nhiều
Làm chủ khái niệm gửi file qua internet
Gia nhập hàng ngũ lập trình viên cao cấp thực sự hiểu cách File được gửi qua internet
Hiểu tại sao đôi khi bạn muốn dùng FileReader để thao tác với dữ liệu nhị phân của file
Hiểu về File API và chunking
Code một server Node.js từ đầu để truyền file
Sử dụng WebSockets để thiết lập dữ liệu signaling cho kênh WebRTC
Làm chủ FileReader API
Đóng kết nối WebRTC một cách nhẹ nhàng, đúng cách!
Hiểu cách một WebRTC data channel và kết nối bên dưới nên đóng một cách nhẹ nhàng
Xác định API nào cần dùng để gửi file bằng WebRTC
Hiểu sự khác biệt giữa sử dụng FileReader API, Streams API và Blobs
Biết cách triển khai nén để gửi file nhanh hơn nữa
Và còn rất nhiều điều thú vị khác nữa!!!
Hiểu thuộc tính binaryType dùng cho data channels trong WebRTC là gì
Thiết lập server HTTP Node từ đầu
Tạo WebSocket server dùng cho WebRTC signaling
Sử dụng AJAX (Fetch API hiện đại) để quản lý trạng thái
Hiểu về WebRTC data channels và sự kiện bufferedamountlow
Làm chủ các khái niệm về Blobs, ArrayBuffers và UInt8Arrays
Và còn nhiều nữa!!!

Yêu cầu

Kiến thức cơ bản về HTTP, CSS và JavaScript
Máy Mac hoặc PC, để bạn có thể code cùng tôi
Kiến thức cơ bản về WebRTC (nếu chưa rõ, bạn có thể tham khóa WebRTC trước của tôi)

Đối tượng phù hợp

Nhà phát triển Web: Nếu bạn là front-end hoặc full-stack developer muốn thêm khả năng truyền file peer-to-peer hiệu quả vào ứng dụng web của mình bằng WebRTC DataChannels, khóa học này sẽ chỉ cho bạn cách triển khai từ đầu đến cuối
Người đam mê JavaScript: Khóa học này hoàn hảo cho những ai có kỹ năng JavaScript vững chắc và muốn đào sâu hiểu biết về lập trình bất đồng bộ, xử lý stream và giao tiếp thời gian thực trên web
Lập trình viên muốn hiểu rõ cách dữ liệu nhị phân và File hoạt động, và phân biệt sự khác nhau giữa Blobs, ArrayBuffers và UInt8Arrays, v.v.
Lập trình viên xây dựng ứng dụng cộng tác: Bất kỳ ai xây dựng tính năng chia sẻ file cho ứng dụng chat, nền tảng cộng tác hoặc công cụ giao tiếp thời gian thực sẽ hưởng lợi từ các phương pháp thực tế và hiểu biết về kiến trúc được dạy ở đây
Nếu bạn muốn thành thạo việc tạo trải nghiệm truyền file mượt mà, hiệu suất cao giữa các trình duyệt mà không phụ thuộc vào server, khóa học này được thiết kế dành riêng cho bạn
Những tâm hồn tò mò sẵn sàng khám phá cách máy tính xem file, và cách chia nhỏ file và gửi chúng qua internet

Nội dung khóa học

9 phần • 117 bài giảng
1 Giới thiệu về phần này
2 Files là gì?
3 Các bước cần thiết để gửi một file qua mạng
4 Tại sao metadata lại quan trọng
5 Chuẩn bị và gửi file bằng mã giả Python
6 Phân tích chi tiết ví dụ về metadata qua TCP
7 Nhận, đọc và tạo file bằng mã giả Python
8 Một cách hiện đại hơn để gửi file qua mạng bằng WebRTC
1 Ai nên học phần này?
2 Tổng quan về HTML và CSS
3 Tạo file JavaScript đầu vào và thiết lập ESModules
4 Thiết lập trạng thái (state) ở phía client
5 "State" trên client là gì?
6 Thiết lập kết nối WebSocket trên client
7 Vai trò của WebSockets với WebRTC
8 Thiết lập logger tùy chỉnh của chúng ta
9 Thiết lập server Node và khởi động server HTTP
10 Thiết lập WebSocket server
11 Thiết lập WebSocket server và trích xuất userId
12 Lưu trạng thái kết nối của người dùng trên server
13 Đăng ký các sự kiện lắng nghe WebSocket trên server
14 Xử lý khi mất kết nối
15 Tổng kết và kiểm tra
1 Xem lại dự án, sửa lỗi nhỏ, và bắt đầu với files
2 Trích xuất session ID của người nhận
3 Mục đích của session ID
4 Gửi yêu cầu AJAX bằng Fetch API để kiểm tra session ID của người nhận
5 Xử lý yêu cầu AJAX trên server
6 Hoàn thiện logic AJAX phía client
7 Kiểm tra yêu cầu AJAX và sửa lỗi nhỏ
8 Giới thiệu về File API
9 File API không chỉ là thẻ `<input type="file">`
10 Tạo file có kích thước 0 byte trong terminal để kiểm tra
11 File Specification và xem bộ nhớ heap trong tab "memory" của trình duyệt
12 Vị trí của file trên hệ thống của người dùng không được tiết lộ cho chúng ta
13 Đảm bảo người dùng không tải file rỗng
14 Hoàn thiện logic kiểm tra tải file lên
15 Kích hoạt nút "Send" và sẵn sàng cho WebRTC
16 Quy trình chúng ta sẽ thực hiện trong khóa học này
1 Tổng quan về cách WebRTC hoạt động
2 Bắt đầu với files
3 Tạo một WebRTC offer
4 Giải thích các hàm createPeerConnection() và createDataChannel()
5 Gửi WebRTC offer đến signaling server
6 Chuyển tiếp offer đến người dùng nhận file
7 Thiết lập các sự kiện lắng nghe tin nhắn đến cho kết nối WebSocket của chúng ta
8 Nhận offer và tạo WebRTC answer
9 Gửi và nhận WebRTC answer
10 Xử lý ICE candidates
11 Đưa các ICE candidates trong mảng vào đối tượng PC
12 Kiểm tra code và kết thúc files
1 Các cách khác nhau trình duyệt có thể đọc file vào bộ nhớ
2 3 cách chính để đọc file và gửi chúng qua WebRTC data channel
3 Kích hoạt code sendFile() của chúng ta
4 Thiết lập phần tử và kiểm tra code
5 Giới thiệu về FileReader API
6 Lỗi trình duyệt và WebRTC nếu dùng FileReader mà không chia nhỏ file
7 Hai lỗi bạn sẽ gặp khi cố gửi file lớn mà không chia nhỏ
8 Xem bộ nhớ heap tăng và giảm trong thời gian thực
9 Array buffers và bộ nhớ (RAM)
10 ArrayBuffer là gì? (giải thích bằng lời của tôi)
11 Chunking và send queue
12 Viết logic để chia nhỏ file
13 Tại sao không phải lúc nào cũng gửi chunk có kích thước tối đa?
14 Tại sao đôi khi cần làm việc với ArrayBuffers
15 Cập nhật giá trị offset, đọc các chunk tiếp theo và cập nhật phần tử progress
16 Kiểm tra code
17 Xem thuộc tính bufferedAmount trên data channel
18 Cách chúng ta phải sử dụng các thuộc tính bufferedAmount và bufferedAmountLowThreshold
19 Tại sao chúng ta phải theo dõi thuộc tính bufferedAmount
20 Thiết lập ngưỡng send queue và bufferedAmountLowThreshold
21 Quản lý kiểm soát tắc nghẽn trong dự án
22 Tạm dừng gửi khi bộ đệm send queue (bufferedAmount) quá đầy
23 Tiếp tục gửi khi sự kiện "bufferedamountlow" được kích hoạt
24 Kiểm tra code gửi và đính kèm files code
25 Cách nhận một file
26 Gửi metadata của file cho bên nhận
27 Đăng ký sự kiện lắng nghe "message" trên data channel của bên nhận
28 Trích xuất file metadata
29 Xử lý chunks và hiển thị thống kê
30 Tạo đối tượng Blob và sử dụng URL interface để tạo liên kết tải xuống
31 Kiểm tra code và thảo luận về logic metadata
32 Tại sao lại tạo một đối tượng Blob duy nhất?
33 Tổng kết về việc tạo đối tượng Blob
34 Đóng kết nối WebRTC và data channel một cách nhẹ nhàng
35 Đóng data channel và đối tượng WebRTC peer connection một cách nhẹ nhàng
36 Xóa bộ nhớ biến
37 Cho phép người dùng "Dừng" gửi file
38 Sửa lỗi undefined
39 Kết thúc files
1 Blobs vs ArrayBuffers và bắt đầu với files
2 Phương thức file.slice() có giống arr.slice() không?
3 Gửi Blobs trực tiếp
4 Thuộc tính binaryType của dataChannel
5 Kết thúc files
1 Giới thiệu về nén và thư viện Pako
2 Nén giúp truyền dữ liệu nhanh hơn
3 Gửi ArrayBuffers đã nén
4 Nhận và giải nén ArrayBuffers
5 Với ảnh có thể hơi phức tạp
6 Nén ảnh có thể khiến file lớn hơn file gốc (thật bất ngờ)
7 Giải pháp dễ dàng - giảm kích thước mỗi chunk gửi qua data channel
8 Giải pháp hai, phần 1 - chỉ nén các file không phải ảnh
9 Giải pháp hai, phần 2 - chỉ giải nén các file không phải ảnh
10 Sửa lỗi và ăn mừng thành công
11 Tổng kết
1 Giới thiệu phần
2 Giới thiệu về Streams API
3 Một số câu hỏi phát sinh từ stream file.stream().getReader()
4 Hãy triển khai File Streams API
5 Bạn có biết?
6 Kiểm tra code và các vấn đề với Streams API
7 Sự khác biệt "thực tế" giữa sử dụng Streams API hiện đại và FileReader
8 Giới thiệu về chế độ BYOB của Streams API
9 Triển khai BYOB và kiểm tra Streams API
10 Kết thúc files
1 Kết thúc

Giới thiệu khóa học

*** THE ONLY WEBRTC COURSE THAT FOCUSES ON WEBRTC DATA CHANNELS TO TRANSFER FILES ***

  • Build a file transfer app using WebRTC DataChannels

  • Understand how data channels can be used for sending files

  • Master the FileReader API, Streams API and Blobs

  • Work with Blobs to assemble received file chunks into a downloadable link

  • Learn the importance of sending file metadata (filename, size, type)

  • Explore chunking strategies to split files into manageable pieces

  • Gain insight into browser memory handling

  • Understanding how to avoid memory bloat by streaming data rather than loading entire files at once

  • Equip yourself with best practices for WebRTC signaling and connection management to build robust and scalable file sharing apps.

  • And more!!!

Feel like diving in and touching the bottom? Now’s your chance. Code an app that sends large files to another device. Bypass servers by using WebRTC.

TWO (OF MANY) REASONS WHY THIS COURSE IS A GAME CHANGER:
#1. You can look forward to an advanced course which is structured to motivate you. Together we build a complete file-sharing project from scratch without relying on servers or intermediaries. This course provides practical skills like no other.

#2. You will use WebRTC for this, which is a modern, private and secure technology. This course covers WebRTC sufficiently for its purposes, but those wanting a more comprehensive overview of WebRTC may consider my specialized WebRTC course."

Other mainstream sites (like SendBig, TransferNow, WeTransfer, etc) use servers and traditional methods to send files. This course teaches you how to build peer-to-peer file transfers using cutting-edge WebRTC technology, making your file sharing faster, more secure, and incredibly efficient. No servers, no middlemen, just direct device-to-device transfer in real time. How amazing is that?

Sending files directly between devices is a critical, high-demand skill in modern web applications, and this course teaches you how to do it using cutting-edge WebRTC. You will master building WebRTC peer-to-peer file transfers that bypass servers completely, ensuring file sharing is fast, secure, and efficient.

Why sending files is complicated?

The journey of transferring a file over WebRTC follows this path:

"file on senders hard drive → browser memory → WebRTC transfer -> receiver’s browser memory → receiver’s disk"

Sounds simple, right?

But here’s the catch: if we try to load the whole file into browser memory at once, we hit RAM limits imposed by browsers. To overcome this, we use chunking, breaking the file into manageable pieces.

But wait, chunking alone isn’t the end of the story. WebRTC data channels weren’t initially designed to handle massive messages. Some browsers like Mozilla allow sending huge fragments—up to 1 GB thanks to their EOR flags—but Chrome is far stricter, limiting fragments to just 250 KB. That’s tiny! So not only do we chunk the file for reading, but we must also send those chunks in small pieces to fit browser protocol limits.

Here’s where it gets tricky: your browser often reads chunks and calls the send() method faster than WebRTC can actually transmit them. This creates a send queue—a backlog that, if ignored, can crash your connection with errors. That’s why you’ll master how to monitor the bufferedAmount and handle the “bufferedamountlow” event, ensuring smooth data flow and keeping your connection stable and alive.

This course makes these complex challenges simple and practical, turning you into a savvy WebRTC file transfer expert!

Why this Course Matters:

  • Secure Peer-to-Peer File Transfer: Learn how WebRTC enables direct device-to-device communication, so no servers are needed to send files.

  • Real Project Setup: Build a native HTTP server with Node.js and create a WebSocket signaling server, then establish a full WebRTC connection.

  • Deep Dive into Files: Understand what files really are at the binary level, and why browsers require files to be read into memory before sending.

  • Practical Use of the FileReader API: Master the most popular API for reading files into browser memory and the necessity of chunking files to avoid RAM limits.

  • Handling WebRTC DataChannel Limits: Discover browser-specific constraints like Chrome’s 250kB max fragment size and strategies for chunking file data and handling the send queue using bufferedAmount and bufferedamountlow events.

  • Adding Compression: Explore optional compression techniques and the challenges of compressing already compressed image formats like PNG and JPEG.

  • Alternatives to FileReader: Learn how to send files as Blobs directly for different developer needs.

  • Modern Streams API: Utilize the Streams API for file transfer, intelligently managing chunk sizes with the "bring your own buffer" (BYOB) method for precise control.

  • Metadata and File Reconstruction: Implement logic to send metadata and reassemble chunks on the receiver side, creating downloadable URLs from blobs with the URL.createObjectURL method.

  • Interactive Learning: Benefit from quizzes, write-ups, and thorough explanations designed to make you a WebRTC file transfer grandmaster.

What You Will Build:
In this course you'll build a fully functional file transfer application that allows a sender to select a file, send it chunk-by-chunk over a WebRTC data channel, and create a download link on the receiver’s end, ready for users to save their files locally.

Course Highlights:

  • Understanding files as computer and browser objects.

  • Setting up essential signaling with WebSocket and Node HTTP servers.

  • Overcoming browser memory limits with chunked reading and sending.

  • Handling WebRTC data channel constraints and send buffer management.

  • Adding file compression with practical caveats and solutions.

  • Exploring multiple APIs including FileReader, Blob transmission, and Streams API with BYOB.

  • Creating reliable file reconstruction and user-friendly download links.

  • Experiential learning through real project code, quizzes, and explanations.

But wait, there's more!

We’ll dive into adding compression options. If you want to squeeze those files down even smaller. Here’s the twist: image files like PNG and JPEG are already compressed by default, so trying to compress them again can blow your mind—and your file size—by making them bigger than the original! Sounds crazy, right? Don’t sweat it though, I’ve got your back, and together we’ll crack that puzzle.

Meet Your Instructor: Clyde
Clyde is a lifelong coding enthusiast who has been hooked on computers since he was 7 years old. With years of hands-on experience in web development and a passion for teaching, he brings a treasure trove of practical knowledge and real-world insights to this course. Known for his engaging and approachable style, Clyde breaks down complex concepts into clear, enjoyable lessons that anyone can follow.

You might be wondering, is he an AI? Nope, Clyde is 100% human (or is this something a robot would say ?!), and he’ll be right there with you throughout every lecture, your dedicated wingman as you tackle challenges, celebrate breakthroughs, and master the skills step by step.

This course is far from a solo adventure. With Clyde as your companion, you’ll feel supported and inspired as you journey from beginner to WebRTC file transfer pro. Let’s get crackin’

Why This Course Is Different:
It’s comprehensive, hands-on, and rooted in real-world challenges like chunking, buffer management, compression issues, and signaling. Unlike generic tutorials, you get deep understanding and practical skills that today’s employers and projects demand.

Enroll now to become an expert in peer-to-peer file transfer with WebRTC. Advance your development skills, build secure, efficient apps, and join a thriving community of forward-thinking web developers.

Let’s get crackin’

Khóa học liên quan

Khám phá thêm các khoá học cùng chủ đề

Hiển thị tất cả khoá học Javascript
Hiển thị tất cả khoá học Real Time Communication
Hiển thị tất cả khoá học Webrtc
Zalo
Tôi có thể tư vấn khoá học cho bạn 😊