Android 및 iOS 앱에서 Dropbox의 파일과 폴더 관리를 가능하게 하는 Dropbox API와 상호작용하는 클라이언트를 제공하는 Flutter 패키지입니다. Dropbox 앱 또는 외부 웹 브라우저를 통해 인증을 지원하여 사용자 계정에 안전한 접근을 보장합니다. 클라우드 스토리지 기능이 필요한 모바일 애플리케이션에 원활하게 통합될 수 있도록 설계되었습니다. 업로드, 다운로드 및 파일 목록 조회와 같은 일반적인 작업을 단순화하여, Dropbox 연결 기능을 갖춘 크로스플랫폼 앱을 개발하는 개발자에게 이상적입니다.
사용 사례
파일 백업 및 동기화
클라우드 문서 저장소
사용자 파일 관리
앱 데이터 지속성
Dropbox 워크플로우와의 통합
주요 기능
Android 및 iOS를 지원합니다
Dropbox 앱 또는 브라우저를 통한 인증
간단한 파일 업로드/다운로드
크로스 플랫폼 호환성
보안 OAuth2 인증
적합한 대상
클라우드 스토리지가 필요한 모바일 앱
사용자 파일 액세스가 필요한 앱
백엔드로 Dropbox를 사용하는 개발자
클라우드 요구 사항이 있는 Flutter 프로젝트
Android 및 iOS 양쪽 모두를 대상으로 하는 앱
고려 사항
인증을 위해 Dropbox 앱 또는 브라우저가 필요합니다
Dropbox 생태계에 제한됨
네트워크 문제에 대한 적절한 오류 처리가 필요합니다
외부 Dropbox API의 안정성에 의존
파일 접근을 위해 사용자 동의가 필요할 수 있습니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
dropbox client
A flutter plugin for accessing Dropbox.
Setup
Register a Dropbox API app from https://www.dropbox.com/developers .
You need a Dropbox app key. Public clients using PKCE do not need an app secret,
and must not embed one in the application.
For Android, add below in AndroidManifest.xml (replace DROPBOXKEY with your key)
<activity
android:name="com.dropbox.core.android.AuthActivity"
android:configChanges="orientation|keyboard"
android:launchMode="singleTask">
<intent-filter>
<!-- Change this to be db- followed by your app key -->
<data android:scheme="db-DROPBOXKEY" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
If you need more help setting up Android, please read https://github.com/dropbox/dropbox-sdk-java#setup .
3.a) If you are using Swift, add below code to AppDelegate.swift
import ObjectiveDropboxOfficial
// should be inside AppDelegate class
override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
if let authResult = DBClientsManager.handleRedirectURL(url) {
if authResult.isSuccess() {
print("dropbox auth success")
} else if (authResult.isCancel()) {
print("dropbox auth cancel")
} else if (authResult.isError()) {
print("dropbox auth error \(authResult.errorDescription)")
}
}
return true
}
// if your are linked with ObjectiveDropboxOfficial 6.x use below code instead
override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
DBClientsManager.handleRedirectURL(url, completion:{ (authResult) in
if let authResult = authResult {
if authResult.isSuccess() {
print("dropbox auth success")
} else if (authResult.isCancel()) {
print("dropbox auth cancel")
} else if (authResult.isError()) {
print("dropbox auth error \(authResult.errorDescription)")
}
}
});
return true
}
3.b) If you are using Objective C, add below code to AppDelegate.m
#import <ObjectiveDropboxOfficial/ObjectiveDropboxOfficial.h>
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
DBOAuthResult *authResult = [DBClientsManager handleRedirectURL:url];
if (authResult != nil) {
if ([authResult isSuccess]) {
NSLog(@"Success! User is logged into Dropbox.");
} else if ([authResult isCancel]) {
NSLog(@"Authorization flow was manually canceled by user!");
} else if ([authResult isError]) {
NSLog(@"Error: %@", authResult);
}
}
return NO;
}
// if your are linked with ObjectiveDropboxOfficial 6.x use below code instead
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
BOOL result = [DBClientsManager handleRedirectURL:url completion: ^(DBOAuthResult *authResult) {
if (authResult != nil) {
if ([authResult isSuccess]) {
NSLog(@"Success! User is logged into Dropbox.");
} else if ([authResult isCancel]) {
NSLog(@"Authorization flow was manually canceled by user!");
} else if ([authResult isError]) {
NSLog(@"Error: %@", authResult);
}
}
}];
return NO;
}
Update Deployment Target to iOS 9.0 or above from Xcode. (dropbox_client 0.7.0 and above)
Add below permissions to your app from Dropbox App Console:
files.metadata.read
files.metadata.write
files.content.read
files.content.write
If you need more help setting up for iOS, please read https://github.com/dropbox/dropbox-sdk-obj-c#get-started .
Usage
import'package:dropbox_client/dropbox_client.dart';
FutureinitDropbox() async {
// Initialize a public client for PKCE. Call only once.awaitDropbox.init(dropbox_clientId, dropbox_key);
}
The optional third argument is retained for legacy confidential-client flows:
// Legacy AuthorizationString accessToken;
FuturetestLogin() async {
// this will run Dropbox app if possible, if not it will run authorization using a web browser.awaitDropbox.authorize();
}
FuturegetAccessToken() async {
accessToken = awaitDropbox.getAccessToken();
}
FutureloginWithAccessToken() async {
awaitDropbox.authorizeWithAccessToken(accessToken);
}
FuturetestLogout() async {
// unlink removes authorizationawaitDropbox.unlink();
}
// OAuth 2 code flow with PKCE that grants a short-lived tokenString credentials;
FuturetestLogin() async {
// this will run Dropbox app if possible, if not it will run authorization using a web browser.awaitDropbox.authorizePKCE();
}
FuturegetCredentials() async {
credentials = awaitDropbox.getCredentials();
}
FutureloginWithCredentials() async {
awaitDropbox.authorizeWithCredentials(credentials);
}
FuturetestLogout() async {
// unlink removes authorizationawaitDropbox.unlink();
}
// List / Upload / DownloadFuturetestListFolder() async {
final result = awaitDropbox.listFolder(''); // list root folderprint(result);
final url = awaitDropbox.getTemporaryLink('/file.txt');
print(url);
}
FuturetestUpload() async {
final filepath = '/path/to/local/file.txt';
final result = awaitDropbox.upload(filepath, '/file.txt', (uploaded, total) {
print('progress $uploaded / $total');
});
}
FuturetestDownload() async {
final filepath = '/path/to/local/file.txt';
final result = awaitDropbox.download('/dropbox_file.txt', filepath, (downloaded, total) {
print('progress $downloaded / $total');
});
}