Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need code example for path param in CreateSharedLinkWithSettingsAsync #64

Closed
ghost opened this issue Oct 20, 2017 · 2 comments
Closed

Comments

@ghost
Copy link

ghost commented Oct 20, 2017

It would be helpful to have a code example in CreateSharedLinkWithSettingsAsync so I could know what value to pass in the path parameter. In my case, an example would be "C:\Users\malter.JOYOUSLIVING\Dropbox\FoldernameLevel1\FolderNameLevel1\FileName.pdf". Do I pass the entire path string or just everything right after Dropbox. Not sure what to pass. Also could use some guidance on the SharedLinkSettings param also. We don't want the filelinks to be public, but only to those people who are authorized to access the folder.

Thank you.

@greg-db
Copy link
Contributor

greg-db commented Oct 20, 2017

The path you supply should be the path in Dropbox, e.g., the Metatdata.pathLower as returned elsewhere in the API. For your sample, that would look like "/foldernamelevel1/foldernamelevel1/filename.pdf".

Here's an example that uses the Dropbox .NET SDK to get a shared link for a file, either by creating a new one with settings, or retrieving an existing one:

SharedLinkMetadata sharedLinkMetadata;
SharedLinkSettings settings = new SharedLinkSettings(requestedVisibility:RequestedVisibility.Password.Instance, expires: DateTime.Now.AddMonths(1), linkPassword: password);
try
{
    sharedLinkMetadata = await this.client.Sharing.CreateSharedLinkWithSettingsAsync(path:path, settings:settings);
}
catch (ApiException<CreateSharedLinkWithSettingsError> err)
{
    if (err.ErrorResponse.IsSharedLinkAlreadyExists)
    {
        var sharedLinksMetadata = await this.client.Sharing.ListSharedLinksAsync(path: path, cursor: null, directOnly: true);
        sharedLinkMetadata = sharedLinksMetadata.Links.First();
    }
    else
    {
        throw err;
    }
}
Console.WriteLine(sharedLinkMetadata.Url);

@greg-db greg-db closed this as completed Oct 20, 2017
@ghost
Copy link
Author

ghost commented Oct 23, 2017

Greg,

This is very helpful. Thank you. I'll let you know how it goes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant