패키지, 저장소 및 앱 카테고리 검색

패키지 상세v1.2.2

dropbox_client

Flutter용 Dropbox 클라이언트입니다. 이 라이브러리는 Android 및 iOS를 지원합니다. 인증은 Dropbox 앱 또는 외부 웹 브라우저를 통해 수행됩니다.

AndroidiOS
30일 다운로드
487
좋아요
42
Pub 점수
140

패키지 설치

flutter pub add dropbox_client

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

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

pub package

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 .

For iOS,

  1. add below in Info.plist

     <key>LSApplicationQueriesSchemes</key>
       <array>
           <string>dbapi-8-emm</string>
           <string>dbapi-2</string>
       </array>
    
  2. add below in Info.plist (replace DROPBOXKEY with your key)

     <key>CFBundleURLTypes</key>
       <array>
         <dict>
           <key>CFBundleURLSchemes</key>
           <array>
             <string>db-DROPBOXKEY</string>
           </array>
           <key>CFBundleURLName</key>
           <string></string>
         </dict>
       </array>
    

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;          
    }
  1. Update Deployment Target to iOS 9.0 or above from Xcode. (dropbox_client 0.7.0 and above)

  2. 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';

Future initDropbox() async {
    // Initialize a public client for PKCE. Call only once.
    await Dropbox.init(dropbox_clientId, dropbox_key);
}

The optional third argument is retained for legacy confidential-client flows:

await Dropbox.init(dropbox_clientId, dropbox_key, dropbox_secret);
// Legacy Authorization
String accessToken;

Future testLogin() async {
  // this will run Dropbox app if possible, if not it will run authorization using a web browser.
  await Dropbox.authorize();
}

Future getAccessToken() async {
  accessToken = await Dropbox.getAccessToken();
}

Future loginWithAccessToken() async {
  await Dropbox.authorizeWithAccessToken(accessToken);
}

Future testLogout() async {
  // unlink removes authorization
  await Dropbox.unlink();
}
// OAuth 2 code flow with PKCE that grants a short-lived token
String credentials;

Future testLogin() async {
  // this will run Dropbox app if possible, if not it will run authorization using a web browser.
  await Dropbox.authorizePKCE();
}

Future getCredentials() async {
  credentials = await Dropbox.getCredentials();
}

Future loginWithCredentials() async {
  await Dropbox.authorizeWithCredentials(credentials);
}

Future testLogout() async {
  // unlink removes authorization
  await Dropbox.unlink();
}
// List / Upload / Download

Future testListFolder() async {
  final result = await Dropbox.listFolder(''); // list root folder
  print(result);
  
  final url = await Dropbox.getTemporaryLink('/file.txt');
  print(url);
}

Future testUpload() async {
  final filepath = '/path/to/local/file.txt';
  final result = await Dropbox.upload(filepath, '/file.txt', (uploaded, total) {
    print('progress $uploaded / $total');
  });
}

Future testDownload() async {
  final filepath = '/path/to/local/file.txt';
  final result = await Dropbox.download('/dropbox_file.txt', filepath, (downloaded, total) {
    print('progress $downloaded / $total');
  });
}

Example can be found in example folder.

카테고리

의존성

의존성 목록 1 개

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.