CloudSix API: add cloud storage support to your app in a nutshell

What is CloudSix?

CloudSix is a set of full client apps for cloud storage services.

The current version only support Dropbox but other cloud storage services will be added as soon as possible, including: OneDrive, Google Drive, Box.com and Mega.co.

But it’s not only a full client app, it’s also an API that can be used by other apps.

What features are available for third-party apps?

Two features can be easily added to your application: a file picker and a file saver.

File Picker

CloudSix provides a way for other apps to select a file on cloud storages. No need to manage authentification, file browsing, file manager, file cache, retrieve data, etc… just with 2 lines of code you can ask CloudSix to do this task for you. Moreover, you can add some filters like “show me only jpg and png files” or “show me only mp4 file < 2Mb”, once launched, CloudSix will only display the kind of files you want and will relaunch your app with the selected file.

File Saver

You can also ask to CloudSix to save a file for you. Once again, just with 2 lines of code. You only need to provide the stream and a file name (the user will be able to change it if he wants)

Do I need to update my app when other cloud storage services will be added?

No, the SDK will not change, support of other cloud services will be automatically

How can I add CloudSix feature to my app?

First you need to add the cloudSix Connector using nuget, to do it, search “CloudSixConnector” in your package manager or write the following line in the package console:

Install-Package CloudSixConnector

The library is very small, only 10kb, no memory or performance impact to your app.

How can I use the file picker?

First you need to create a custom file extension to communicate with CloudSix.

Open your WMAppManifest.xml file and add the following line to the Extensions node (replace MyAppName by your app name):

<FileTypeAssociation Name="Associated with CloudSix" NavUriFragment="fileToken=%s" TaskID="_default">
<SupportedFileTypes>
<FileType ContentType="application/cloudsix2MyAppName">.cloudsix2MyAppName</FileType>
</SupportedFileTypes>
</FileTypeAssociation>

This file protocol will be used to pass the file data from cloudsix to your app.

Create a CloudSixPicker object and give it the file protocol you previously set.

var launcher = new CloudSixPicker("cloudsix2MyAppName");

To manage and trace your request, you can add a token, re-sent with the file data (‘.’ will be automatically replaced by ‘_’)

launcher.Token = "FromCloudSix";

You can also add a caption, displayed in the cloudsix header (no need to add your app name, it will be automatically displayed):

launcher.Caption = "select a file (image or video <1Mb)";

cloudsixcaption

Then you can select the file types you want (file extension (case insensitive and maximum file size):

launcher.FileExtensions.Add(new CloudSixFileExtension() { Extension = "jpg" });
launcher.FileExtensions.Add(new CloudSixFileExtension() { Extension = "png" });
launcher.FileExtensions.Add(new CloudSixFileExtension() { Extension = "mp4", MaxFileSizeInKb = 1000 });

Here is the full example:

var launcher = new CloudSixPicker("cloudsix2sixsnap");
launcher.Caption = "select a file (image or video <1Mb)";
launcher.Token = "FromCloudSix";
launcher.FileExtensions.Add(new CloudSixFileExtension() { Extension = "jpg" });
launcher.FileExtensions.Add(new CloudSixFileExtension() { Extension = "png" });
launcher.FileExtensions.Add(new CloudSixFileExtension() { Extension = "mp4", MaxFileSizeInKb = 1000 });
launcher.Show();

To get the cloudsix answer, you need to add a UriMapper to your app

//in App.xaml.cs
RootFrame.UriMapper = new UriMapper();
internal class UriMapper : UriMapperBase
{

public  override Uri MapUri(Uri uri)
{

if (uri.StartsWith("/FileTypeAssociation"))
{
// Get the file ID (after "fileToken=").
int fileIDIndex = tempUri.IndexOf("fileToken=") + 10;
string fileID = tempUri.Substring(fileIDIndex);

var fileinfo=CloudSixPicker.GetAnswer(fileID);

//display the right page

return new Uri("VideoPlayerPage.xaml?fileid="+HttpUtility.UrlEncode(fileID),UriKind.Relative);

}
return uri;
}
}

and in VideoPlayerPage.xaml.cs

var file=await fileinfo.CopySharedFileAsync(NavigationContext.QueryString["fileid"]);

 

How can I use the file saver?

To save a file, it’s very simple, just create a CloudSixSaver object with the stream you want to save as well as a name file (can be altered by the user).

var saver = new CloudSixSaver("Zelda.gba", myfilestream);
await saver.Launch();

You can add a callback if you want, just add a protocol extension:

<Protocol Name="yourappname" NavUriFragment="encodedLaunchUri=%s" TaskID="_default" />-->
saver.AppCustomExtension = "yourappname";

The protocol extension will be called by CloudSix once the file saved with the following format:

yourappname:cloudsiximportresult?result=saved&originfilename=[the filename set by your app]&filepath=[the path where the file has been saved]

Warning: the user can change the filename, filepath takes into account the user filename whereas originfilename takes into account the filename the third party app set (to trace result).

How much it costs ?

Nothing, the app is available for free and will remain free.

 

Do I need a dropbox developer key?

No. All actions are made by the CloudSix app. The library doesn’t contain dropbox API or dropbox references, it only contains some codes to launch CloudSix with parameters. So to summarize, using the file picker and file saver features only launches CloudSix with some parameters, nothing else. One launched only CloudSix runs and let users to select folder, make actions, etc… So CloudSix is the only responsable of all transactions.