public static async Task <SharedLinkMetadata> CreateFileShareLink(DropboxClient client, Metadata file, RequestedVisibility requestedVisibility, string password) { SharedLinkSettings settings = new SharedLinkSettings(); if (requestedVisibility.IsPassword) { if (password == null) { //TODO: Add error handling return(new SharedLinkMetadata()); } settings = new SharedLinkSettings(requestedVisibility, password); } else { settings = new SharedLinkSettings(requestedVisibility); } CreateSharedLinkWithSettingsArg arg = new CreateSharedLinkWithSettingsArg(file.PathLower, settings); try { return(await client.Sharing.CreateSharedLinkWithSettingsAsync(arg)); } catch (ApiException <CreateSharedLinkWithSettingsError> error) { //TODO: Add error handling return(new SharedLinkMetadata()); } }
/// <summary> /// <para>Begins an asynchronous send to the create shared link with settings /// route.</para> /// </summary> /// <param name="path">The path to be shared by the shared link</param> /// <param name="settings">The requested settings for the newly created shared /// link</param> /// <param name="callback">The method to be called when the asynchronous send is /// completed.</param> /// <param name="callbackState">A user provided object that distinguished this send /// from other send requests.</param> /// <returns>An object that represents the asynchronous send request.</returns> public sys.IAsyncResult BeginCreateSharedLinkWithSettings(string path, SharedLinkSettings settings = null, sys.AsyncCallback callback = null, object callbackState = null) { var createSharedLinkWithSettingsArg = new CreateSharedLinkWithSettingsArg(path, settings); return this.BeginCreateSharedLinkWithSettings(createSharedLinkWithSettingsArg, callback, callbackState); }
/// <summary> /// <para>Create a shared link with custom settings. If no settings are given then the /// default visibility is <see cref="Dropbox.Api.Sharing.RequestedVisibility.Public" /> /// (The resolved visibility, though, may depend on other aspects such as team and /// shared folder settings).</para> /// </summary> /// <param name="path">The path to be shared by the shared link</param> /// <param name="settings">The requested settings for the newly created shared /// link</param> /// <returns>The task that represents the asynchronous send operation. The TResult /// parameter contains the response from the server.</returns> /// <exception cref="Dropbox.Api.ApiException{TError}">Thrown if there is an error /// processing the request; This will contain a <see /// cref="CreateSharedLinkWithSettingsError"/>.</exception> public t.Task<SharedLinkMetadata> CreateSharedLinkWithSettingsAsync(string path, SharedLinkSettings settings = null) { var createSharedLinkWithSettingsArg = new CreateSharedLinkWithSettingsArg(path, settings); return this.CreateSharedLinkWithSettingsAsync(createSharedLinkWithSettingsArg); }
/// <summary> /// <para>Begins an asynchronous send to the create shared link with settings /// route.</para> /// </summary> /// <param name="createSharedLinkWithSettingsArg">The request parameters.</param> /// <param name="callback">The method to be called when the asynchronous send is /// completed.</param> /// <param name="state">A user provided object that distinguished this send from other /// send requests.</param> /// <returns>An object that represents the asynchronous send request.</returns> public sys.IAsyncResult BeginCreateSharedLinkWithSettings(CreateSharedLinkWithSettingsArg createSharedLinkWithSettingsArg, sys.AsyncCallback callback, object state = null) { var task = this.CreateSharedLinkWithSettingsAsync(createSharedLinkWithSettingsArg); return enc.Util.ToApm(task, callback, state); }
/// <summary> /// <para>Create a shared link with custom settings. If no settings are given then the /// default visibility is <see cref="Dropbox.Api.Sharing.RequestedVisibility.Public" /> /// (The resolved visibility, though, may depend on other aspects such as team and /// shared folder settings).</para> /// </summary> /// <param name="createSharedLinkWithSettingsArg">The request parameters</param> /// <returns>The task that represents the asynchronous send operation. The TResult /// parameter contains the response from the server.</returns> /// <exception cref="Dropbox.Api.ApiException{TError}">Thrown if there is an error /// processing the request; This will contain a <see /// cref="CreateSharedLinkWithSettingsError"/>.</exception> public t.Task<SharedLinkMetadata> CreateSharedLinkWithSettingsAsync(CreateSharedLinkWithSettingsArg createSharedLinkWithSettingsArg) { return this.Transport.SendRpcRequestAsync<CreateSharedLinkWithSettingsArg, SharedLinkMetadata, CreateSharedLinkWithSettingsError>(createSharedLinkWithSettingsArg, "api", "/sharing/create_shared_link_with_settings", Dropbox.Api.Sharing.CreateSharedLinkWithSettingsArg.Encoder, Dropbox.Api.Sharing.SharedLinkMetadata.Decoder, Dropbox.Api.Sharing.CreateSharedLinkWithSettingsError.Decoder); }