Publish File

One of the greates features of DropBox - possibility of publishing file. You can upload file into Public folder and receive URI to this file: for example you are creating application which publishes photos from your photocamera to DropBox and shares link to this photo on Twitter.

To publish file please use next code:

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            Action<string> callback = PublishCompleted;

            DropBoxy.DropBoxyEngine engine = new DropBoxy.DropBoxyEngine();
            engine.ApiKey = "api key";
            engine.ApiSecret = "api secret";

            engine.SetToken("usertoken", "usersecret");

            engine.PublishFile(new byte[] { 32, 32, 32 }, "/newtxt/txt.txt", callback);
        }

This peace of code will publish file with byte content, to the folder newtxt in the folder Public with the name "txt.txt". URI to this file will be returned to the callback function.

In case you already have file on Public folder, you can just receive URI to this file. Please refer to the next code as an example:

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            Action<string> callback = URIRetrievingCompleted;

            DropBoxy.DropBoxyEngine engine = new DropBoxy.DropBoxyEngine();
            engine.ApiKey = "api key";
            engine.ApiSecret = "api secret";

            engine.SetToken("usertoken", "usersecret");

            engine.GetPublicLink("/newtxt/txt.txt", callback);
        }
This code will return public link to the just published file:)

Last edited Jan 16, 2011 at 10:31 AM by dimko1, version 2

Comments

No comments yet.