सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।
एक फ्लटर प्लगइन जो iOS और macOS ऐप्स को ऐप के iCloud कंटेनर में फ़ाइलों को अपलोड, डाउनलोड और प्रबंधित करने की अनुमति देता है। यह iCloud के फ़ाइल स्टोरेज सिस्टम के साथ बातचीत करने के लिए एक सीधी-सादी इंटरफ़ेस प्रदान करता है, जिससे उपयोगकर्ता डेटा को डिवाइस के बीच बिना किसी रुकावट के सिंक करना संभव होता है। यह प्लगइन विशेष रूप से Apple प्लेटफॉर्म के लिए डिज़ाइन किया गया है, और भरोसेमंद और सुरक्षित फ़ाइल हैंडलिंग के लिए मूल iCloud API का उपयोग करता है। डेवलपर्स इसका उपयोग करके डॉक्यूमेंट्स, मीडिया या ऐप-विशिष्ट डेटा को iCloud में स्टोर कर सकते हैं, जिससे जटिल क्लाउड इंफ्रास्ट्रक्चर के प्रबंधन की आवश्यकता नहीं होती है। यह pub.dev के माध्यम से फ्लटर प्रोजेक्ट में सीधे एकीकृत होता है।
उपयोग
Apple उपकरणों के बीच उपयोगकर्ता दस्तावेज़ सिंक करना
iCloud में ऐप-विशिष्ट डेटा संग्रहीत करना
मीडिया फ़ाइलों को स्वतः बैकअप करें
iCloud में संग्रहीत सामग्री के ऑफलाइन पहुँच को सक्षम करना
iCloud में फ़ाइल संस्करणों का प्रबंधन करें
मुख्य विशेषताएँ
iOS और macOS में मूल आईक्लाउड एकीकरण
सरल अपलोड और डाउनलोड विधियाँ
एप्प कंटेनर में फ़ाइल प्रबंधन
स्वचालित उपकरण सिंक्रनाइज़ेशन
सुरक्षित, एन्क्रिप्टेड स्टोरेज
इनके लिए उपयुक्त
iCloud समर्थन की आवश्यकता वाले iOS और macOS Flutter ऐप्स
क्रॉस-डिवाइस डेटा सिंक की आवश्यकता वाले ऐप्स
iCloud का उपयोग करने वाले दस्तावेज़-आधारित एप्लिकेशन
केवल एप्पल इकोसिस्टम के लिए डेवलपर्स
न्यूनतम बादल इंफ्रास्ट्रक्चर की आवश्यकता वाले प्रोजेक्ट
विचार योग्य बातें
केवल iOS और macOS प्लेटफॉर्म पर उपलब्ध
ऐप कॉन्फ़िगरेशन में iCloud एंटिलमेंट्स की आवश्यकता होती है
Apple के iCloud सेवा तक सीमित
Android या वेब प्लेटफॉर्म के लिए समर्थन नहीं है
उपयोगकर्ता के iCloud खाते और स्टोरेज सीमाओं पर निर्भर करता है
मूल README
संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।
icloud_storage
A flutter plugin for upload, download and manage files in the app's iCloud container.
Introduction
Documents and other data that is user-generated and stored in the <Application_Home>/Documents directory can be automatically backed up by iCloud on iOS devices, if the iCloud Backup setting is turned on. The data can be recovered when user sets up a new device or resets an existing device. If you need to do backup and download outside the forementioned scenarios, this plugin could help.
Prerequisite
The following setups are needed in order to use this plugin:
An apple developer account
Created an App ID and iCloud Container ID
Enabled iCloud capability and assigned iCloud Container ID for the App ID
Note: The 'startUpload' API is to start the upload process. The returned future completes without waiting for the upload to complete. Use 'onProgress' to track the upload progress. If the 'destinationRelativePath' contains a subdirectory that doesn't exist, it will be created.
Note: The 'startDownload' API is to start the download process. The returned future completes without waiting for the download to complete. Use 'onProgress' to track the download progress.
catch (err) {
if (err isPlatformException) {
if (err.code == PlatformExceptionCode.iCloudConnectionOrPermission) {
print(
'Platform Exception: iCloud container ID is not valid, or user is not signed in for iCloud, or user denied iCloud permission for this app');
} elseif (err.code == PlatformExceptionCode.fileNotFound) {
print('File not found');
} else {
print('Platform Exception: ${err.message}; Details: ${err.details}');
}
} else {
print(err.toString());
}
}
Support for macOS
When uploading and downloading files, make sure the File Access is enabled for the local files if App Sandbox is enabled. Access are enabled for the files in the app's container (/Users/{username}/Library/Containers/{bundle_identifier}). Files in other locations can be enabled from XCode.
Migrating from version 1.x.x to 2.0.0
Version 2 supports operations on multiple containers. Therefore, ICloudStorage.getInstance('iCloudContainerId') is no longer needed. Instead, you'll need to specifiy the iCloudContainerId in each method.
All methods in version 2 have been changed to static methods.
gatherFiles has been renamed to gather.
startUpload has been renamed to upload.
startDownload has been renamed to download.
FAQ
Q: I uploaded a file from a device. I signed in to a simulator using the same iCloud account. But the file is not showing up in the gatherFiles result.
A: From the menu 'Features' click 'Tigger iCloud Sync'.
Q: I uploaded a file from device A. I signed in to device B using the same iCloud account. But the file is not showing up in the gatherFiles result.
A: The API only queries files that's been synced to the iCloud container, which lives in the local device. You'll need to wait for iOS to sync the files from iCloud to the local container. There's no way to programmatically trigger iOS to Sync with iCloud.
Q: I removed a file using 'delete' method then called 'gatherFiles'. The deleted file still shows up in the list.
A: This is most likely to be an issue with the native code. However, if you call 'gatherFiles' first and listen the update, then do the deletion, the list is refreshed immediately in the onUpdate stream.
How to set up iCloud Container and enable the capability
Log in to your apple developer account and select 'Certificates, IDs & Profiles' from the left navigation.
Select 'Identifiers' from the 'Certificates, IDs & Profiles' page, create an App ID if you haven't done so, and create an iCloud Containers ID.
Click on your App ID. In the Capabilities section, select 'iCloud' and assign the iCloud Container created in step 2 to this App ID.
Open your project in Xcode. Set your App ID as 'Bundle Identifier' if you haven't done so. Click on '+ Capability' button, select iCloud, then tick 'iCloud Documents' in the Services section and select your iCloud container.