This project is read-only.

How to get Public Url

Jul 1, 2011 at 12:40 PM

Hi, is it possible to get the public Url (Share Url/Public Link Url) of a file in Public folder in Dropbox? Can't find it..?

Best regards

Mattias

Jul 6, 2011 at 9:20 PM
Hi,

sorry for the late reply. Normally you can get direct uri via the following code

// open the publicFilder
ICloudDirectoryEntry publicFolder = cloudStorage.GetFolder(testBaseFolderServerData);

// get the direct url to the pptx
Uri uri = cloudStorage.GetFileSystemObjectUrl("DirectDownloadTest.pptx", publicFolder);

This returns an URI which contains a bunch of oAuth parameter. If you want to get the original public URI from dropbox I added a new feature in our dropbox storage provider tool stack. You can use the following code if you build the sharpbox trunk tree:

ICloudDirectoryEntry fEntry = cs.GetFolder("/Public");
ICloudFileSystemEntry fs = cs.GetFileSystemObject("xxx.txt", fEntry);

Uri uri = DropBoxStorageProviderTools.GetPublicObjectUrl(tk, fs);
I hope this helps?
Cheers
Dirk

2011/7/1 matengo <notifications@codeplex.com>

From: matengo

Hi, is it possible to get the public Url (Share Url/Public Link Url) of a file in Public folder in Dropbox? Can't find it..?

Best regards

Mattias

Read the full discussion online.

To add a post to this discussion, reply to this email (sharpbox@discussions.codeplex.com)

To start a new discussion for this project, email sharpbox@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Aug 17, 2011 at 4:23 AM

Hello,

Is there any way to get a temporary URL for a file in any (not necessarily public) folder? 

I'm thinking in something similar to what Amazon S3 allows (http://docs.amazonwebservices.com/sdkfornet/latest/apidocs/html/M_Amazon_S3_AmazonS3_GetPreSignedURL.htm), 

Many thanks,

Horacio.-

Nov 21, 2012 at 1:40 PM

Hey Horacio! After struggling with fragmented documentation (tutorial 1 and 2 on Sharpbox codeplex site), here is what I found, and it is working

            ICloudStorageAccessToken accessToken = null;
            string accessTokenString = @"you will paste a big 64 based string here after first run";

            CloudStorage dropBoxStorage = new CloudStorage();
            DropBoxConfiguration config = CloudStorage.GetCloudConfigurationEasy(nSupportedCloudConfigurations.DropBox) as DropBoxConfiguration;
            if (accessTokenString == @"you will paste a big 64 based string here after first run")
            {
                const string ConsumerKey = "your consumer key";
                const string ComsumerSecret = "your consumer secret key";

                config.AuthorizationCallBack = new Uri("http://anysitehere.org");

                DropBoxRequestToken requestToken = DropBoxStorageProviderTools.GetDropBoxRequestToken(config, ConsumerKey, ComsumerSecret);
                String authorizationUrl = DropBoxStorageProviderTools.GetDropBoxAuthorizationUrl(config, requestToken);

                //put a breakpoint here in the next line over accessToken, visit the site in authorizationUrl to authorize it your app 
                accessToken = DropBoxStorageProviderTools.ExchangeDropBoxRequestTokenIntoAccessToken(config, ConsumerKey, ComsumerSecret, requestToken);

                //do not loose the next string, it will help you avoid authorize your app every time.
                //put this result string in the top of your code
                accessTokenString = dropBoxStorage.SerializeSecurityTokenToBase64Ex(accessToken, typeof(ICloudStorageAccessToken), null);
            }
            else
                accessToken = dropBoxStorage.DeserializeSecurityTokenFromBase64(accessTokenString);

            var storageToken = dropBoxStorage.Open(config, accessToken);
            var publicFolder = dropBoxStorage.GetFolder("/");
            foreach (var fof in publicFolder)
            {
                // check if we have a directory 
                Boolean bIsDirectory = fof is ICloudDirectoryEntry;
                System.Diagnostics.Trace.WriteLine(string.Format("{0}: {1}", bIsDirectory ? "DIR" : "FIL", fof.Name));
            }
            dropBoxStorage.Close();
Nov 22, 2012 at 9:33 AM
Edited Nov 22, 2012 at 9:34 AM

Hi how this  code will work  i am passing my api key and api secret in above code and   if  i want to get accesstoken value i need to login into my dropbox account than only i will get my accesstoken  i am able to build url but it will not allow me to login into my dropbox account

when i tring to run it i am getting error "attempt to perform unauthorised operation"

Nov 22, 2012 at 8:22 PM

Hello.

What you are trying to do here is basicly what DropBoxTokenIssuer is for, as far as I have been able to understand, but it does not seem to work anymore. 

Is someone able to fix the DropBoxTokenIssuer?

Nov 8, 2013 at 6:27 PM
Hi I am Using Sharpbox Dll

Now that I want my users to use the share functionality for the users by sharing the link I have tried several ways and could not find any answer.

My requirement when I click on share an link should go to the recipient email when click on the link it should download file.

Below is the code I am using.

path is file name ...
    public string ShareobjectLink(string tokenString, string path)
        {
        CloudStorage cs = new CloudStorage();

        storage.Open(configuration, accessToken);
        using (Stream tokenStream = new MemoryStream(ASCIIEncoding.Default.GetBytes(tokenString)))
            {
            StreamWriter writer = new StreamWriter(tokenStream, Encoding.UTF8, 256);
            accessToken = storage.DeserializeSecurityToken(tokenStream) as ICloudStorageAccessToken;
            }

        ICloudStorageAccessToken tk = storage.Open(configuration, accessToken);
        //using (Stream tokenStream = new MemoryStream(ASCIIEncoding.Default.GetBytes(tokenString)))
        //    {
        //    StreamWriter writer = new StreamWriter(tokenStream, Encoding.UTF8, 256);
        //    accessToken = storage.DeserializeSecurityToken(tokenStream) as ICloudStorageAccessToken;
        //    }

        // no public we are in sandbox mode
        var fEntry = storage.GetFolder("/Public");

            }
I am getting error at fEntry as

Couldn't retrieve child elements from the server