2012年3月15日 星期四

[cloud] Upload File to DropBox using C#

Upload File to DropBox using C#

Jing (mqJing@gmail.com)

Get the Knowledge: 20 minitues

Outline

  1. Build Environment (2 steps)
  2. Sample Code (< 20 lines)

Download

Build Environment (2 steps)
Step 1: Download the SharpBox SDK,

http://sharpbox.codeplex.com/


Step 2: 登入DropBox 申請專屬 application

https://www.dropbox.com/developers/apps


Sample Code

Step 1: 取得使用者的存取授權 (get the access token)

說明: SharpBox 提供了工具, 裡面包含簡單的程序包裝了 OAuth 1.0 的程序, 向使用者取得同意 真正發布程式時, 你應該修改 DropBoxTokenIssuer.exe 並且在 user 端執行.

作法: 執行 ShapBox SDK DropBoxTokenIssuer.exe.

(按下 Authorize, 程式會將access token 放到指定位置)

在取得授權之前, 使用者會先被要求登入 DropBox, 以提供授權.

使用者 tom_jing 所看到的要求授權畫面

Step 2:

(a) 開啟專案後, 記得指定 reference library

作法: [References]->[Browse] -> [AppLimit.CloudComputing.SharpBox.dll]

(b) 把 SharpBox xxx/ net40-full 裡面的 *.dll 複製到你的專案執行位置 (這樣才會找到相關的 dll)


Sample Code (download)

Step 3: Set the Target Framework as .NET Framework 4

Enjoy!

by Jing.

Reference

  1. Johan Silfversparre, "Unboxing Dropbox and SharpBox", http://blog.jayway.com/2012/02/06/unboxing-dropbox-and-sharpbox-2/