You can use the SendFile API to upload files from Object Storage Service (OSS) to a specified folder on a Cloud Phone instance. You can also use a public download link to upload an application package to a specified folder on multiple Cloud Phone instances and automatically install the application. This topic describes four typical use cases that demonstrate how to use this API to distribute files and applications.
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 to which you want to send the file has Internet access permissions.
The first Cloud Phone instance has sufficient storage space for the file or application to be distributed.
You have activated OSS. In this scenario, only the first Cloud Phone instance downloads the file or application from the Internet. The instance then uploads the file or application 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.
In this scenario, 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. However, because it uses a default OSS bucket as a transit point, it also incurs additional storage costs. 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, you can call the DescribeTasks API to query the progress and status of the task using the returned TaskId.
Use case comparison
Use cases 1 and 2: If the file or application package that you want to distribute is stored in an OSS bucket in the same region as the Cloud Phone instances, Cloud Phone distributes it over the internal network. This process does not consume Internet traffic.
Use cases 3: If the file or application package that you want to distribute is on the Internet, Cloud Phone downloads multiple copies from the Internet and distributes them to your Cloud Phone instances. This process consumes Internet traffic.
Use case 4: If the file or application package that you want to distribute is on the Internet, Cloud Phone downloads one copy of the file or package from the Internet. It then caches the copy in an OSS bucket that you own and is in the same region. Then, it distributes the copy to all other Cloud Phone instances over the internal network. This process consumes only a small amount of Internet traffic.