My Headlines

Monday, August 20, 2007

File Sharing Online with Box.net

by Don Burnett

*WARNING* FIRST PARAGRAPH -A BIT OFF TOPIC

iPhone Support

Wow Box.net how great is this? This is a little bit off-topic, but a lot of people who are developing WPF and Silverlight applications, and Box.net is a very well liked company for more than a couple of reasons. So can we marry the two? They have won numerous awards for making it easy to store your files online and make them available in workgroup applications. They support accessing your files in a number of unexpected places including mobile devices, Facebook.com, and a number of other web 2.0 type platforms...

Their latest wonder is now connectivity support for the iPhone..

This allows you to access your online file storage at box.net right from your Apple iPhone.. The navigation is pretty simple, like a normal iPhone application. Seems to work flawlessly as well.. It's fast and efficient on the iPhone too.

Microsoft Expression Blend Meets Box (Introduction)

Box.Net provides a very open API for developers. You can access file sharing and Box's services directly from SOAP, XML POST, or REST API's. That means we can use them right from Expression Blend's XML data source giving Blend WPF and Silverlight instant access to online files and sharing. This opens up a whole new realm of functionality to Blend RIA developers..

First Steps (Please Note most of this is paraphrased in Box.NET's very COMPLETE developer documentation):

You'll need to sign up and obtain a Box.net API key, since you'll need to pass in your API key with every API call you make.

Box.net API authentication provides a secure way for users to authenticate with Box.net without having to share their Box.net user name or password with you. This provides a consistent, safe experience for users and makes things easier on you (since you don't have to store user credentials).
To obtain an authentication ticket, your application performs these steps:

  • Obtain an authentication ticket by calling the get_ticket API method.
  • Redirect the user to the Box.net API authentication page, passing the ticket you obtained from the get_ticket call as a query string parameter
  • The user then authenticates by entering their user name and password on the authentication page
After the user has authenticated, the next step depends on whether you're writing a web application or a client application.
If you're writing a web application, Box.net redirects the user to a page called the callback page. This is a page that resides on your site (you should have designated this page when you set up your application). The authentication appends a ticket variable to the end of this URL

For client applications, the user is shown a message instructing them to return to the application after they've authenticated. The application then calls get_auth_token with the ticket parameter to retrieve the authorization token.
At this point, you'll probably either want to show the user the files in their Box or enable them to upload a file to their Box.

To show a complete list of the user's files and folders, use the get_account_tree call. This call retrieves an XML document describing the entire contents of the user's box, including files and folders. You can then databind this to a XAML treeview control in Blend. You could also pass the ID of a folder as a parameter to this call, enabling your application to retrieve a subset of the tree structure.

To upload a file, your application performs an HTTP POST using a URL of the form:

http://upload.box.net/api/upload/<auth_token>/<folder_id>
At the time you upload a file using HTTP POST, you can also specify whether you want the file to be publicly sharable (as described in the Upload and Download reference documentation). You can also share a file after it's been uploaded using the public_share API if you prefer.

It's that simple to work with.

This service was almost made for Blend users and is easy to implement thanks to it's support of XML and REST API's.

To Be Continued...

In an upcoming posting, I will do a walk through of creating a file sharing application using Box.Net using Expression Blend in both WPF and Silverlight that is both accessible online from the Silverlight plug-in and as full Windows WPF platform application.

No comments: