The SendFile API allows you to upload files from Object Storage Service (OSS) to a specified folder on Cloud Phone instances, or use a public download link to distribute and automatically install application packages. This topic covers four typical use cases for file and application distribution.
Prerequisites
-
General prerequisites for all use cases:
-
All target Cloud Phone instances are in the same region.
-
The status of all target Cloud Phone instances is Active.
-
-
Specific prerequisites for Use case 4 (Internet download and internal distribution):
-
The first Cloud Phone instance has Internet access permissions.
-
The first Cloud Phone instance has sufficient storage space for the file or application.
-
You have activated OSS. In this scenario, only the first Cloud Phone instance downloads the file or application from the Internet and uploads it to an OSS bucket that you own in the same region.
ImportantOSS storage incurs additional costs. For more information, see Billing overview.
-
Use case 1: Upload a regular file
Use case
You need to upload the file snapshot.png from an OSS bucket in the China (Hangzhou) region to the /sdcard/Pictures folder on the Cloud Phone instances acp-c8rzmx8fnwba6**** and acp-5fc8mx8fnw9s5**** in the same region.
SendFile API call example
-
Request message
{ "AndroidInstanceIdList": [ "acp-c8rzmx8fnwba6****", "acp-5fc8mx8fnw9s5****" ], "SourceFilePath": "/sdcard/Pictures", "UploadType": "OSS", "UploadUrl": "oss://cloudphone-saved-bucket-cn-hangzhou-****/picture/snapshot.png", "UploadEndpoint": "oss-cn-hangzhou-internal.aliyuncs.com" } -
Response message
{ "TaskId": "t-gk0ahswe4blor****", "RequestId": "5D6FB544-F20E-14F8-B627-3F32C337****", "Data": [ { "TaskId": "t-gk0ahswe4blor****", "AndroidInstanceId": "acp-c8rzmx8fnwba6****" }, { "TaskId": "t-gk0ahswe4blor****", "AndroidInstanceId": "acp-5fc8mx8fnw9s5****" } ] }
Use case 2: Upload and automatically install an application package
Use case
You have an application package named SogouInput_12.15.0_android_sweb.apk in an OSS bucket in the China (Hangzhou) region. You need to perform the following tasks:
-
Upload the package to the
/sdcard/Downloadfolder on the Cloud Phone instancesacp-c8rzmx8fnwba6****andacp-5fc8mx8fnw9s5****in the China (Hangzhou) region. -
Rename it to
sougou.apk. -
Automatically install the application after the upload completes.
SendFile API call example
-
Request message
{ "AndroidInstanceIdList": [ "acp-c8rzmx8fnwba6****", "acp-5fc8mx8fnw9s5****" ], "SourceFilePath": "/sdcard/Download", "UploadType": "OSS", "UploadUrl": "oss://cloudphone-saved-bucket-cn-hangzhou-****/app/SogouInput_12.15.0_android_sweb.apk", "UploadEndpoint": "oss-cn-hangzhou-internal.aliyuncs.com", "TargetFileName": "sougou.apk", "AutoInstall": "true" } -
Response message
{ "TaskId": "t-gk0ahswe4blor****", "RequestId": "5D6FB544-F20E-14F8-B627-3F32C337****", "Data": [ { "TaskId": "t-gk0ahswe4blor****", "AndroidInstanceId": "acp-c8rzmx8fnwba6****" }, { "TaskId": "t-gk0ahswe4blor****", "AndroidInstanceId": "acp-5fc8mx8fnw9s5****" } ] }
Use case 3: Download and automatically install an application package from the Internet (individual download mode)
Use case
You have a download link for an application package: https://apkdl.example.com/wapdl/android/apk/SogouInput_12.15.0_android_sweb.apk. You need to perform the following tasks:
-
The Cloud Phone instances
acp-c8rzmx8fnwba6****andacp-5fc8mx8fnw9s5****in the China (Hangzhou) region individually download the package from the Internet, save it to the/sdcard/Downloadfolder, and rename it tosougou.apk. -
Automatically install the application after the download completes.
SendFile API call example
-
Request message
{ "AndroidInstanceIdList": [ "acp-c8rzmx8fnwba6****", "acp-5fc8mx8fnw9s5****" ], "SourceFilePath": "/sdcard/Download/sougou.apk", "UploadType": "DOWNLOAD_URL", "UploadUrl": "https://apkdl.example.com/wapdl/android/apk/SogouInput_12.15.0_android_sweb.apk", "AutoInstall": "true" } -
Response message
{ "TaskId": "t-gk0ahswe4blor****", "RequestId": "5D6FB544-F20E-14F8-B627-3F32C337****", "Data": [ { "TaskId": "t-gk0ahswe4blor****", "AndroidInstanceId": "acp-c8rzmx8fnwba6****" }, { "TaskId": "t-gk0ahswe4blor****", "AndroidInstanceId": "acp-5fc8mx8fnw9s5****" } ] }
Use case 4: Download and automatically install an application package from the Internet (Internet download and internal distribution mode)
Use case
You have a download link for an application package: https://apkdl.example.com/wapdl/android/apk/SogouInput_12.15.0_android_sweb.apk. You need to perform the following tasks:
-
Cloud Phone instance 1,
acp-c8rzmx8fnwba6****, in the China (Hangzhou) region, which has Internet access, downloads the package from the Internet. It then saves the package to the/sdcard/Downloadfolder, renames it tosougou.apk, and automatically installs the application. -
Upload the package over the internal network to a default OSS bucket that you own in the same region.
-
Distribute the package over the internal network to other specified Cloud Phone instances in the same region, such as Cloud Phone instance 2
acp-5fc8mx8fnw9s5****, and then automatically install the application.
-
The first Cloud Phone instance must have Internet access permissions and sufficient storage space. Otherwise, the application package cannot be downloaded and stored.
-
Compared to Use case 3, this use case reduces data transfer costs but incurs additional OSS storage costs because it uses a default OSS bucket as a transit point. Choose the use case that best suits your needs.
SendFile API call example
-
Request message
{ "AndroidInstanceIdList": [ "acp-c8rzmx8fnwba6****", "acp-5fc8mx8fnw9s5****" ], "SourceFilePath": "/sdcard/Download", "UploadType": "OSS_BRIDGED", "UploadUrl": "https://apkdl.example.com/wapdl/android/apk/SogouInput_12.15.0_android_sweb.apk", "UploadEndpoint": "oss-cn-hangzhou-internal.aliyuncs.com", "TargetFileName": "sougou.apk", "AutoInstall": "true" } -
Response message
{ "TaskId": "t-gk0ahswe4blor****", "RequestId": "5D6FB544-F20E-14F8-B627-3F32C337****", "Data": [ { "TaskId": "t-gk0ahswe4blor****", "AndroidInstanceId": "acp-c8rzmx8fnwba6****" }, { "TaskId": "t-gk0ahswe4blor****", "AndroidInstanceId": "acp-5fc8mx8fnw9s5****" } ] }
Next steps
After the API call succeeds, call the DescribeTasks API to query the task progress and status by using the returned TaskId.
Use case comparison
-
Use cases 1 and 2: If the file or application package is stored in an OSS bucket in the same region as the Cloud Phone instances, distribution occurs over the internal network and does not consume Internet traffic.
-
Use cases 3: If the file or application package is on the Internet, each Cloud Phone instance downloads its own copy. This consumes Internet traffic.
-
Use case 4: If the file or application package is on the Internet, one Cloud Phone instance downloads it and caches it in an OSS bucket that you own in the same region. The cached copy is then distributed to all other Cloud Phone instances over the internal network, consuming only a small amount of Internet traffic.