1e41f4b71Sopenharmony_ci# @ohos.file.cloudSync (Device-Cloud Synchronization)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThe **cloudSync** module provides the device-cloud synchronization capabilities for applications. You can use the APIs to start or stop device-cloud synchronization and start or stop the download of images.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **NOTE**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci## Modules to Import
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci```ts
12e41f4b71Sopenharmony_ciimport { cloudSync } from '@kit.CoreFileKit';
13e41f4b71Sopenharmony_ci```
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ci## State<sup>11+</sup>
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ciEnumerates the download states of a cloud file.
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci**System capability**: SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci| Name|  Value|  Description|
22e41f4b71Sopenharmony_ci| ----- |  ---- |  ---- |
23e41f4b71Sopenharmony_ci| RUNNING |  0 | The cloud file is being downloaded.|
24e41f4b71Sopenharmony_ci| COMPLETED |  1 | The cloud file download is complete.|
25e41f4b71Sopenharmony_ci| FAILED |  2 | The cloud file download failed.|
26e41f4b71Sopenharmony_ci| STOPPED |  3 | The cloud file download is stopped.|
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ci## DownloadProgress<sup>11+</sup>
29e41f4b71Sopenharmony_ci
30e41f4b71Sopenharmony_ciRepresents information about the download progress of a cloud file.
31e41f4b71Sopenharmony_ci
32e41f4b71Sopenharmony_ci**System capability**: SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
33e41f4b71Sopenharmony_ci
34e41f4b71Sopenharmony_ci| Name    | Type  | Mandatory| Description|
35e41f4b71Sopenharmony_ci| ---------- | ------ | ---- | ---- |
36e41f4b71Sopenharmony_ci| state | [State](#state11) | Yes  | File download state.|
37e41f4b71Sopenharmony_ci| processed | number | Yes  | Size of the data downloaded.|
38e41f4b71Sopenharmony_ci| size | number | Yes  | Size of the cloud file.|
39e41f4b71Sopenharmony_ci| uri | string | Yes  | URI of the cloud file.|
40e41f4b71Sopenharmony_ci| error | [DownloadErrorType](#downloaderrortype11) | Yes  | Download error type.|
41e41f4b71Sopenharmony_ci
42e41f4b71Sopenharmony_ci## CloudFileCache<sup>11+</sup>
43e41f4b71Sopenharmony_ci
44e41f4b71Sopenharmony_ciProvides APIs for the file manager application to download files from the Drive Kit to a local device.
45e41f4b71Sopenharmony_ci
46e41f4b71Sopenharmony_ci**System capability**: SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
47e41f4b71Sopenharmony_ci
48e41f4b71Sopenharmony_ci### construct<sup>11+</sup>
49e41f4b71Sopenharmony_ci
50e41f4b71Sopenharmony_ciconstructor()
51e41f4b71Sopenharmony_ci
52e41f4b71Sopenharmony_ciA constructor used to create a **CloudFileCache** instance.
53e41f4b71Sopenharmony_ci
54e41f4b71Sopenharmony_ci**System capability**: SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
55e41f4b71Sopenharmony_ci
56e41f4b71Sopenharmony_ci**Error codes**
57e41f4b71Sopenharmony_ci
58e41f4b71Sopenharmony_ci| ID                    | Error Message       |
59e41f4b71Sopenharmony_ci| ---------------------------- | ---------- |
60e41f4b71Sopenharmony_ci| 401 | The input parameter is invalid. Possible causes:Incorrect parameter types. |
61e41f4b71Sopenharmony_ci
62e41f4b71Sopenharmony_ci**Example**
63e41f4b71Sopenharmony_ci
64e41f4b71Sopenharmony_ci  ```ts
65e41f4b71Sopenharmony_ci  let fileCache = new cloudSync.CloudFileCache();
66e41f4b71Sopenharmony_ci  ```
67e41f4b71Sopenharmony_ci
68e41f4b71Sopenharmony_ci### on<sup>11+</sup>
69e41f4b71Sopenharmony_ci
70e41f4b71Sopenharmony_cion(event: 'progress', callback: Callback\<DownloadProgress>): void
71e41f4b71Sopenharmony_ci
72e41f4b71Sopenharmony_ciRegisters a listener for the download progress of a file from the Drive Kit.
73e41f4b71Sopenharmony_ci
74e41f4b71Sopenharmony_ci**System capability**: SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
75e41f4b71Sopenharmony_ci
76e41f4b71Sopenharmony_ci**Parameters**
77e41f4b71Sopenharmony_ci
78e41f4b71Sopenharmony_ci| Name    | Type  | Mandatory| Description|
79e41f4b71Sopenharmony_ci| ---------- | ------ | ---- | ---- |
80e41f4b71Sopenharmony_ci| event | string | Yes  | Event type. The value is **progress**, which indicates the download progress event of a file from the Drive Kit.|
81e41f4b71Sopenharmony_ci| callback | Callback\<[DownloadProgress](#downloadprogress11)> | Yes  | Callback for the download progress event of a file from the Drive Kit.|
82e41f4b71Sopenharmony_ci
83e41f4b71Sopenharmony_ci**Error codes**
84e41f4b71Sopenharmony_ci
85e41f4b71Sopenharmony_ciFor details about the error codes, see [File Management Error Codes](errorcode-filemanagement.md).
86e41f4b71Sopenharmony_ci
87e41f4b71Sopenharmony_ci| ID                    | Error Message       |
88e41f4b71Sopenharmony_ci| ---------------------------- | ---------- |
89e41f4b71Sopenharmony_ci| 401 | The input parameter is invalid. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
90e41f4b71Sopenharmony_ci| 13600001  | IPC error. |
91e41f4b71Sopenharmony_ci
92e41f4b71Sopenharmony_ci**Example**
93e41f4b71Sopenharmony_ci
94e41f4b71Sopenharmony_ci  ```ts
95e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
96e41f4b71Sopenharmony_ci  let fileCache = new cloudSync.CloudFileCache();
97e41f4b71Sopenharmony_ci  let callback = (pg: cloudSync.DownloadProgress) => {
98e41f4b71Sopenharmony_ci    console.info("download state: " + pg.state);
99e41f4b71Sopenharmony_ci  };
100e41f4b71Sopenharmony_ci
101e41f4b71Sopenharmony_ci  try {
102e41f4b71Sopenharmony_ci    fileCache.on('progress', callback);
103e41f4b71Sopenharmony_ci  } catch (e) {
104e41f4b71Sopenharmony_ci    const error = e as BusinessError;
105e41f4b71Sopenharmony_ci    console.error(`Error code: ${error.code}, message: ${error.message}`);
106e41f4b71Sopenharmony_ci  }
107e41f4b71Sopenharmony_ci  ```
108e41f4b71Sopenharmony_ci
109e41f4b71Sopenharmony_ci### off<sup>11+</sup>
110e41f4b71Sopenharmony_ci
111e41f4b71Sopenharmony_cioff(event: 'progress', callback?: Callback\<DownloadProgress>): void
112e41f4b71Sopenharmony_ci
113e41f4b71Sopenharmony_ciUnregisters a listener for the download progress of a file from the Drive Kit.
114e41f4b71Sopenharmony_ci
115e41f4b71Sopenharmony_ci**System capability**: SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
116e41f4b71Sopenharmony_ci
117e41f4b71Sopenharmony_ci**Parameters**
118e41f4b71Sopenharmony_ci
119e41f4b71Sopenharmony_ci| Name    | Type  | Mandatory| Description|
120e41f4b71Sopenharmony_ci| ---------- | ------ | ---- | ---- |
121e41f4b71Sopenharmony_ci| event | string | Yes  | Event type. The value is **progress**, which indicates the download progress event of a file from the Drive Kit.|
122e41f4b71Sopenharmony_ci| callback | Callback\<[DownloadProgress](#downloadprogress11)> | No  | Callback to unregister. If this parameter is not specified, this API unregisters all callbacks for the download progress event.|
123e41f4b71Sopenharmony_ci
124e41f4b71Sopenharmony_ci**Error codes**
125e41f4b71Sopenharmony_ci
126e41f4b71Sopenharmony_ciFor details about the error codes, see [File Management Error Codes](errorcode-filemanagement.md).
127e41f4b71Sopenharmony_ci
128e41f4b71Sopenharmony_ci| ID                    | Error Message       |
129e41f4b71Sopenharmony_ci| ---------------------------- | ---------- |
130e41f4b71Sopenharmony_ci| 401 | The input parameter is invalid. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
131e41f4b71Sopenharmony_ci| 13600001  | IPC error. |
132e41f4b71Sopenharmony_ci
133e41f4b71Sopenharmony_ci**Example**
134e41f4b71Sopenharmony_ci
135e41f4b71Sopenharmony_ci  ```ts
136e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
137e41f4b71Sopenharmony_ci  let fileCache = new cloudSync.CloudFileCache();
138e41f4b71Sopenharmony_ci
139e41f4b71Sopenharmony_ci  let callback = (pg: cloudSync.DownloadProgress) => {
140e41f4b71Sopenharmony_ci    console.info("download state: " + pg.state);
141e41f4b71Sopenharmony_ci  }
142e41f4b71Sopenharmony_ci
143e41f4b71Sopenharmony_ci  try {
144e41f4b71Sopenharmony_ci    fileCache.on('progress', callback);
145e41f4b71Sopenharmony_ci    fileCache.off('progress', callback);
146e41f4b71Sopenharmony_ci  } catch (e) {
147e41f4b71Sopenharmony_ci    const error = e as BusinessError;
148e41f4b71Sopenharmony_ci    console.error(`Error code: ${error.code}, message: ${error.message}`);
149e41f4b71Sopenharmony_ci  }
150e41f4b71Sopenharmony_ci  ```
151e41f4b71Sopenharmony_ci
152e41f4b71Sopenharmony_ci### start<sup>11+</sup>
153e41f4b71Sopenharmony_ci
154e41f4b71Sopenharmony_cistart(uri: string): Promise&lt;void&gt;
155e41f4b71Sopenharmony_ci
156e41f4b71Sopenharmony_ciStarts to download a file from the Drive Kit to the local device. This API uses a promise to return the result.
157e41f4b71Sopenharmony_ci
158e41f4b71Sopenharmony_ci**System capability**: SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
159e41f4b71Sopenharmony_ci
160e41f4b71Sopenharmony_ci**Parameters**
161e41f4b71Sopenharmony_ci
162e41f4b71Sopenharmony_ci| Name    | Type  | Mandatory| Description|
163e41f4b71Sopenharmony_ci| ---------- | ------ | ---- | ---- |
164e41f4b71Sopenharmony_ci| uri | string | Yes  | URI of the file to download.|
165e41f4b71Sopenharmony_ci
166e41f4b71Sopenharmony_ci**Return value**
167e41f4b71Sopenharmony_ci
168e41f4b71Sopenharmony_ci| Type                 | Description            |
169e41f4b71Sopenharmony_ci| --------------------- | ---------------- |
170e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise used to return the result.|
171e41f4b71Sopenharmony_ci
172e41f4b71Sopenharmony_ci**Example**
173e41f4b71Sopenharmony_ci
174e41f4b71Sopenharmony_ci  ```ts
175e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
176e41f4b71Sopenharmony_ci  import { fileUri } from '@kit.CoreFileKit';
177e41f4b71Sopenharmony_ci  let fileCache = new cloudSync.CloudFileCache();
178e41f4b71Sopenharmony_ci  let path = "/data/storage/el2/cloud/1.txt";
179e41f4b71Sopenharmony_ci  let uri = fileUri.getUriFromPath(path);
180e41f4b71Sopenharmony_ci
181e41f4b71Sopenharmony_ci  try {
182e41f4b71Sopenharmony_ci    fileCache.on('progress', (pg: cloudSync.DownloadProgress) => {
183e41f4b71Sopenharmony_ci      console.info("download state:" + pg.state);
184e41f4b71Sopenharmony_ci    });
185e41f4b71Sopenharmony_ci  } catch (e) {
186e41f4b71Sopenharmony_ci    const error = e as BusinessError;
187e41f4b71Sopenharmony_ci    console.error(`Error code: ${error.code}, message: ${error.message}`);
188e41f4b71Sopenharmony_ci  }
189e41f4b71Sopenharmony_ci
190e41f4b71Sopenharmony_ci  fileCache.start(uri).then(() => {
191e41f4b71Sopenharmony_ci    console.info("start download successfully");
192e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
193e41f4b71Sopenharmony_ci    console.error("start download failed with error message: " + err.message + ", error code: " + err.code);
194e41f4b71Sopenharmony_ci  });
195e41f4b71Sopenharmony_ci  ```
196e41f4b71Sopenharmony_ci
197e41f4b71Sopenharmony_ci**Error codes**
198e41f4b71Sopenharmony_ci
199e41f4b71Sopenharmony_ciFor details about the error codes, see [File Management Error Codes](errorcode-filemanagement.md).
200e41f4b71Sopenharmony_ci
201e41f4b71Sopenharmony_ci| ID                    | Error Message       |
202e41f4b71Sopenharmony_ci| ---------------------------- | ---------- |
203e41f4b71Sopenharmony_ci| 401 | The input parameter is invalid. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
204e41f4b71Sopenharmony_ci| 13600001  | IPC error. |
205e41f4b71Sopenharmony_ci| 13900002 | No such file or directory. |
206e41f4b71Sopenharmony_ci| 13900025 | No space left on device. |
207e41f4b71Sopenharmony_ci| 14000002 | Invalid uri. |
208e41f4b71Sopenharmony_ci
209e41f4b71Sopenharmony_ci### start<sup>11+</sup>
210e41f4b71Sopenharmony_ci
211e41f4b71Sopenharmony_cistart(uri: string, callback: AsyncCallback&lt;void&gt;): void
212e41f4b71Sopenharmony_ci
213e41f4b71Sopenharmony_ciStarts to download a file from the Drive Kit to the local device. This API uses an asynchronous callback to return the result.
214e41f4b71Sopenharmony_ci
215e41f4b71Sopenharmony_ci**System capability**: SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
216e41f4b71Sopenharmony_ci
217e41f4b71Sopenharmony_ci**Parameters**
218e41f4b71Sopenharmony_ci
219e41f4b71Sopenharmony_ci| Name    | Type  | Mandatory| Description|
220e41f4b71Sopenharmony_ci| ---------- | ------ | ---- | ---- |
221e41f4b71Sopenharmony_ci| uri | string | Yes  | URI of the file to download.|
222e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
223e41f4b71Sopenharmony_ci
224e41f4b71Sopenharmony_ci**Error codes**
225e41f4b71Sopenharmony_ci
226e41f4b71Sopenharmony_ciFor details about the error codes, see [File Management Error Codes](errorcode-filemanagement.md).
227e41f4b71Sopenharmony_ci
228e41f4b71Sopenharmony_ci| ID                    | Error Message       |
229e41f4b71Sopenharmony_ci| ---------------------------- | ---------- |
230e41f4b71Sopenharmony_ci| 401 | The input parameter is invalid. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
231e41f4b71Sopenharmony_ci| 13600001  | IPC error. |
232e41f4b71Sopenharmony_ci| 13900002 | No such file or directory. |
233e41f4b71Sopenharmony_ci| 13900025 | No space left on device. |
234e41f4b71Sopenharmony_ci| 14000002 | Invalid uri. |
235e41f4b71Sopenharmony_ci
236e41f4b71Sopenharmony_ci**Example**
237e41f4b71Sopenharmony_ci
238e41f4b71Sopenharmony_ci  ```ts
239e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
240e41f4b71Sopenharmony_ci  import { fileUri } from '@kit.CoreFileKit';
241e41f4b71Sopenharmony_ci  let fileCache = new cloudSync.CloudFileCache();
242e41f4b71Sopenharmony_ci  let path = "/data/storage/el2/cloud/1.txt";
243e41f4b71Sopenharmony_ci  let uri = fileUri.getUriFromPath(path);
244e41f4b71Sopenharmony_ci
245e41f4b71Sopenharmony_ci  fileCache.start(uri, (err: BusinessError) => {
246e41f4b71Sopenharmony_ci    if (err) {
247e41f4b71Sopenharmony_ci      console.error("start download failed with error message: " + err.message + ", error code: " + err.code);
248e41f4b71Sopenharmony_ci    } else {
249e41f4b71Sopenharmony_ci      console.info("start download successfully");
250e41f4b71Sopenharmony_ci    }
251e41f4b71Sopenharmony_ci  });
252e41f4b71Sopenharmony_ci  ```
253e41f4b71Sopenharmony_ci
254e41f4b71Sopenharmony_ci### stop<sup>11+</sup>
255e41f4b71Sopenharmony_ci
256e41f4b71Sopenharmony_cistop(uri: string, needClean?: boolean): Promise&lt;void&gt;
257e41f4b71Sopenharmony_ci
258e41f4b71Sopenharmony_ciStops downloading a file from the Drive Kit to the local device. This API uses a promise to return the result.
259e41f4b71Sopenharmony_ci
260e41f4b71Sopenharmony_ciCalling **stop** will terminate the download of the current file and clear the cache file. You can use **start** to start the download again.
261e41f4b71Sopenharmony_ci
262e41f4b71Sopenharmony_ci**System capability**: SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
263e41f4b71Sopenharmony_ci
264e41f4b71Sopenharmony_ci**Parameters**
265e41f4b71Sopenharmony_ci
266e41f4b71Sopenharmony_ci| Name    | Type  | Mandatory| Description|
267e41f4b71Sopenharmony_ci| ---------- | ------ | ---- | ---- |
268e41f4b71Sopenharmony_ci| uri | string | Yes  | URI of the file to download.|
269e41f4b71Sopenharmony_ci| needClean<sup>12+</sup> | boolean | No  | Whether to delete the downloaded files. By default, downloaded files are deleted.<br>This parameter is available since API version 12.|
270e41f4b71Sopenharmony_ci
271e41f4b71Sopenharmony_ci**Return value**
272e41f4b71Sopenharmony_ci
273e41f4b71Sopenharmony_ci| Type                 | Description            |
274e41f4b71Sopenharmony_ci| --------------------- | ---------------- |
275e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise used to return the result.|
276e41f4b71Sopenharmony_ci
277e41f4b71Sopenharmony_ci**Error codes**
278e41f4b71Sopenharmony_ci
279e41f4b71Sopenharmony_ciFor details about the error codes, see [File Management Error Codes](errorcode-filemanagement.md).
280e41f4b71Sopenharmony_ci
281e41f4b71Sopenharmony_ci| ID                    | Error Message       |
282e41f4b71Sopenharmony_ci| ---------------------------- | ---------- |
283e41f4b71Sopenharmony_ci| 401 | The input parameter is invalid. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
284e41f4b71Sopenharmony_ci| 13600001  | IPC error. |
285e41f4b71Sopenharmony_ci| 13900002 | No such file or directory. |
286e41f4b71Sopenharmony_ci| 14000002 | Invalid URI. |
287e41f4b71Sopenharmony_ci
288e41f4b71Sopenharmony_ci**Example**
289e41f4b71Sopenharmony_ci
290e41f4b71Sopenharmony_ci  ```ts
291e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
292e41f4b71Sopenharmony_ci  import { fileUri } from '@kit.CoreFileKit';
293e41f4b71Sopenharmony_ci  let fileCache = new cloudSync.CloudFileCache();
294e41f4b71Sopenharmony_ci  let path = "/data/storage/el2/cloud/1.txt";
295e41f4b71Sopenharmony_ci  let uri = fileUri.getUriFromPath(path);
296e41f4b71Sopenharmony_ci
297e41f4b71Sopenharmony_ci  fileCache.stop(uri, true).then(() => {
298e41f4b71Sopenharmony_ci    console.info("stop download successfully");
299e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
300e41f4b71Sopenharmony_ci    console.error("stop download failed with error message: " + err.message + ", error code: " + err.code);
301e41f4b71Sopenharmony_ci  });
302e41f4b71Sopenharmony_ci  ```
303e41f4b71Sopenharmony_ci
304e41f4b71Sopenharmony_ci### stop<sup>11+</sup>
305e41f4b71Sopenharmony_ci
306e41f4b71Sopenharmony_cistop(uri: string, callback: AsyncCallback&lt;void&gt;): void
307e41f4b71Sopenharmony_ci
308e41f4b71Sopenharmony_ciStops downloading a file from the Drive Kit to the local device. This API uses an asynchronous callback to return the result.
309e41f4b71Sopenharmony_ci
310e41f4b71Sopenharmony_ciCalling **stop** will terminate the download of the current file and clear the cache file. You can use **start** to start the download again.
311e41f4b71Sopenharmony_ci
312e41f4b71Sopenharmony_ci**System capability**: SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
313e41f4b71Sopenharmony_ci
314e41f4b71Sopenharmony_ci**Parameters**
315e41f4b71Sopenharmony_ci
316e41f4b71Sopenharmony_ci| Name    | Type  | Mandatory| Description|
317e41f4b71Sopenharmony_ci| ---------- | ------ | ---- | ---- |
318e41f4b71Sopenharmony_ci| uri | string | Yes  | URI of the file to download.|
319e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
320e41f4b71Sopenharmony_ci
321e41f4b71Sopenharmony_ci**Error codes**
322e41f4b71Sopenharmony_ci
323e41f4b71Sopenharmony_ciFor details about the error codes, see [File Management Error Codes](errorcode-filemanagement.md).
324e41f4b71Sopenharmony_ci
325e41f4b71Sopenharmony_ci| ID                    | Error Message       |
326e41f4b71Sopenharmony_ci| ---------------------------- | ---------- |
327e41f4b71Sopenharmony_ci| 401 | The input parameter is invalid. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
328e41f4b71Sopenharmony_ci| 13600001  | IPC error. |
329e41f4b71Sopenharmony_ci| 13900002 | No such file or directory. |
330e41f4b71Sopenharmony_ci| 14000002 | Invalid URI. |
331e41f4b71Sopenharmony_ci
332e41f4b71Sopenharmony_ci**Example**
333e41f4b71Sopenharmony_ci
334e41f4b71Sopenharmony_ci  ```ts
335e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
336e41f4b71Sopenharmony_ci  import { fileUri } from '@kit.CoreFileKit';
337e41f4b71Sopenharmony_ci  let fileCache = new cloudSync.CloudFileCache();
338e41f4b71Sopenharmony_ci  let path = "/data/storage/el2/cloud/1.txt";
339e41f4b71Sopenharmony_ci  let uri = fileUri.getUriFromPath(path);
340e41f4b71Sopenharmony_ci
341e41f4b71Sopenharmony_ci  fileCache.stop(uri, (err: BusinessError) => {
342e41f4b71Sopenharmony_ci    if (err) {
343e41f4b71Sopenharmony_ci      console.error("stop download failed with error message: " + err.message + ", error code: " + err.code);
344e41f4b71Sopenharmony_ci    } else {
345e41f4b71Sopenharmony_ci      console.info("stop download successfully");
346e41f4b71Sopenharmony_ci    }
347e41f4b71Sopenharmony_ci  });
348e41f4b71Sopenharmony_ci  ```
349e41f4b71Sopenharmony_ci
350e41f4b71Sopenharmony_ci## DownloadErrorType<sup>11+</sup>
351e41f4b71Sopenharmony_ci
352e41f4b71Sopenharmony_ciEnumerates the device-cloud download error types.
353e41f4b71Sopenharmony_ci
354e41f4b71Sopenharmony_ci**System capability**: SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
355e41f4b71Sopenharmony_ci
356e41f4b71Sopenharmony_ci| Name|  Value|  Description|
357e41f4b71Sopenharmony_ci| ----- |  ---- |  ---- |
358e41f4b71Sopenharmony_ci| NO_ERROR |  0 | No error.|
359e41f4b71Sopenharmony_ci| UNKNOWN_ERROR |  1 | Unknown error.|
360e41f4b71Sopenharmony_ci| NETWORK_UNAVAILABLE |  2 | The network is unavailable.|
361e41f4b71Sopenharmony_ci| LOCAL_STORAGE_FULL |  3 | The local space is insufficient.|
362e41f4b71Sopenharmony_ci| CONTENT_NOT_FOUND |  4 | The file is not found in the cloud space.|
363e41f4b71Sopenharmony_ci| FREQUENT_USER_REQUESTS |  5 | The user requests are too frequent to respond.|
364