multi_cloud_storage 0.2.0
multi_cloud_storage: ^0.2.0 copied to clipboard
A Flutter plugin for multi-cloud storage that supports Google Drive, iCloud, Dropbox, and OneDrive.
Multi Cloud Storage #
A Flutter plugin that provides a unified API for interacting with multiple cloud storage providers including Dropbox, Google Drive, and OneDrive.
Supported Platforms #
| Service | Android | iOS | Mac | Windows |
|---|---|---|---|---|
| OneDrive | ✅ | ✅ | ✅ | ✅ |
| Google Drive | ✅ | ✅ | ✅ | ❌ |
| Dropbox | ✅ | ✅ | ❌ | ❌ |
Installation #
Add the following to your pubspec.yaml file:
dependencies:
multi_cloud_storage: ^your_version_here
Run:
flutter pub get
Cloud Providers Setup #
Dropbox #
- Register Your App:
- Visit Dropbox App Console.
- Click "Create app".
- Select Scoped access and appropriate access type (
app folderorfull Dropbox). - Generate access token for testing (user login doesn't work while app is Status: Development)
- Obtain your
App Key,App SecretandAccess Token. - Set Redirect URI (OAuth), not required for mobile apps.
Android
Add this to /android/app/src/main/AndroidManifest.xml inside the application bloc and repolace YOUR_APP_KEY with the appKey:
<!-- Add Dropbox Auth Activity -->
<activity
android:name="com.dropbox.core.android.AuthActivity"
android:exported="true"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="db-YOUR_APP_KEY" />
</intent-filter>
</activity>
Google Drive #
-
Setup Google Drive API:
- Go to Google Cloud Console Credentials.
- Create Credentials -> OAuth client ID. ()
- Select "Android", "iOS", or "Web" based on your needs. (Make sure all data is correct for your app or else it won't work)
OneDrive #
-
Register Your App:
- Go to Azure Portal App registration.
- Click
New registration. - For native apps set Redirect URI to
https://login.microsoftonline.com/common/oauth2/nativeclient. - Obtain your
Client ID.
Usage #
import 'package:multi_cloud_storage/multi_cloud_storage.dart';
void main() async {
// Connect to GoogleDrive
final googleDrive = await MultiCloudStorage.connectToGoogleDrive(); // App registration required: https://console.cloud.google.com/auth/overview?inv=1&invt=AbwVjA&project=serious-mariner-457313-i7
// Upload a file
final uploadedPath = await googleDrive.uploadFile(
localPath: '/local/path/to/file.txt',
remotePath: '/remote/path/file.txt',
);
print('Uploaded to: $uploadedPath');
// List files in a folder
final files = await googleDrive.listFiles(path: '/remote/path');
for (final file in files) {
print('Found file: ${file.name} (${file.path})');
}
// Download a file
final localFile = await googleDrive.downloadFile(
remotePath: '/remote/path/file.txt',
localPath: '/local/path/downloaded.txt',
);
print('Downloaded to: $localFile');
// Delete a file
await googleDrive.deleteFile('/remote/path/file.txt');
print('File deleted');
}
Features #
- Unified interface for multiple cloud storage providers.
- Upload, download, delete, and manage files.
- Create and list directories.
- Retrieve file metadata.
Contribution #
Feel free to submit pull requests and report issues.
License #
Distributed under the MIT License. See LICENSE for more information.