dropbox_api 0.0.6
dropbox_api: ^0.0.6 copied to clipboard
A Dart client for the Dropbox API that provides easy access to Dropbox's file operations including upload, download, copy, move, and more.
📂 DropboxApi #
A Dart package that provides convenient access to the Dropbox API, built on top of oauth2restclient
.
✨ Features #
- 🔐 OAuth2 authentication via
oauth2restclient
- 📄 List, upload, download, copy, move, rename, and delete Dropbox files
- 🗂 List and create folders
- 💡 Easy access to Dropbox Streams and metadata
- 📁 Supports only personal and not teams
📦 Installation #
Add to your pubspec.yaml
:
dependencies:
dropbox_api: ^0.0.1
copied to clipboard
🚀 Getting Started #
import 'package:dropbox_api/dropbox_api.dart';
import 'package:oauth2restclient/oauth2restclient.dart';
void main() async {
final account = OAuth2Account();
// Add Dropbox as an OAuth2 provider
account.addProvider(Dropbox(
clientId: "YOUR_CLIENT_ID",
redirectUri: "YOUR_REDIRECT_URI",
scopes: [
"files.metadata.read",
"files.content.read",
"files.content.write"
],
));
// Login or load token
final token = await account.newLogin("dropbox");
final client = await account.createClient(token);
// Initialize API
final dropbox = DropboxApi(client);
// List files in the root
final contents = await dropbox.listFolder("");
for (final entry in contents.entries) {
print("${entry.name} (${entry.path})");
}
}
copied to clipboard
📂 Example Operations #
- List Files:
await dropbox.listFolder("", limit: 20);
copied to clipboard
- Upload File:
await dropbox.upload("/example.txt", fileStream, mode: "add", autorename: true);
copied to clipboard
- Create Folder:
await dropbox.createFolder("/New Folder");
copied to clipboard
- Download File:
final stream = await dropbox.download("/example.txt");
copied to clipboard
- Copy File:
await dropbox.copy("/source.txt", "/target.txt");
copied to clipboard
- Move/Rename File:
await dropbox.move("/oldname.txt", "/newname.txt");
copied to clipboard
- Delete File:
await dropbox.delete("/example.txt");
copied to clipboard
🔗 Dependencies #
📄 License #
MIT License © Heebaek Choi