This feature supports phones and tablets by default. Starting from version 5.1.0(18), support for wearables is added. From version 5.1.1(19), TVs are also supported. From version 6.1.0(23), PCs/2-in-1 devices are supported as well.
Add the network permission to the entry/src/main/module.json5 file.
"requestPermissions": [
{
"name": "ohos.permission.INTERNET"
}
] (Optional) If Cloud Storage operations (such as uploading or downloading files) require users to sign in to the app, you need to perform the following operations:
(Optional) Customize initialization parameters.
To customize initialization parameters used by APIs of Cloud Storage, such as the network type or task mode, refer to the following configuration.
Import required modules.
import { cloudCommon } from '@kit.CloudFoundationKit';
import { request } from '@kit.BasicServicesKit'; Use StorageOptions.network to configure the network type used by APIs of Cloud Storage. If it is not set, the default value request.agent.Network.ANY is used. Use StorageOptions.mode to configure the working mode of Cloud Storage upload and download tasks. If it is not set, the default value request.agent.Mode.BACKGROUND is used.
cloudCommon.init({
storageOptions: {
network: request.agent.Network.WIFI,
mode: request.agent.Mode.FOREGROUND
}
});