DEV Community

HarmonyOS
HarmonyOS

Posted on

What are the differences between the upload and download functions of @ohos.request and RCP?

Read the original article:What are the differences between the upload and download functions of @ohos.request and RCP?

Question

What is the difference between @ohos.request and rcp for upload/download functionalities? How to choose when implementing upload/download requirements?

Short Answer

Differences and Use Cases:

  • @ohos.request: Optimized for multi-file uploads, background transfers, resumable downloads, and large file handling.

  • rcp: Better for single-file transfers, custom protocols, certificate validation, cross-device communication, and high-performance streaming.

  • Choose @ohos.request for simplicity in HTTP(S) upload/download with advanced transfer features.

  • Choose rcp for complex scenarios requiring custom protocols, certificate handling, or low-level control.

Feature @ohos.request rcp
Multi-file Support ✅ Supports batch uploads ❌ Only single file
Background Transfer ✅ Supports background tasks ❌ Foreground only
Resume (Chunked) ✅ Auto-handled ❌ Manual implementation required
Streaming Support ❌ Not supported ✅ Supported
Custom Protocol ❌ Not supported ✅ Supported
Custom Certificate ❌ Not supported ✅ Supported
Cross-device ❌ Not supported ✅ Supported
Proxy Usage ❌ Not supported ✅ Supported

Applicable Scenarios

@ohos.request (Upload/Download):

  • Background downloads/uploads.
  • Resumable (chunked) transfers.
  • Multi-file batch uploads.
  • Large file transfers.
  • Quick implementation for standard HTTP(S) upload/download.

rcp:

  • Single-file or streaming transfers.
  • Custom protocols (e.g., NTLM, digital signature validation).
  • Cross-device communication.
  • Custom certificate validation.
  • High-performance or low-level transmission control.

Reference Links

https://developer.huawei.com/consumer/en/doc/harmonyos-references/remote-communication-rcp#section163819131811

Written by Mehmet Algul

Top comments (0)