Ejemplo n.º 1
0
        /// <summary>
        /// Uploads given content to a file in the Microsoft OneDrive Cloud Storage with an existing refresh token.
        /// </summary>
        /// <param name="ll">current instance of List & Label</param>
        /// <param name="uploadParameters">requied parameters for Microsoft OneDrive OAuth 2.0 upload silently.</param>
        /// <param name="credentials">requied parameters for Microsoft OneDrive OAuth 2.0 authentication.</param>
        public static void UploadSilently(this Reporting.ListLabel ll, MicrosoftOneDriveUploadParameter uploadParameters, MicrosoftOneDriveCredentials credentials)
        {
            // Initialize the GraphServiceClient.
            GraphServiceClient graphClient = SDKHelper.GetAuthenticatedClient(credentials.RefreshToken, uploadParameters.ApplicationId, credentials.ApplicationSecret, credentials.Scope, credentials.RedirectUri);

            // Add the file.
            UploadLargeFile(graphClient, uploadParameters.UploadStream, string.Concat(uploadParameters.CloudPath, "/", uploadParameters.CloudFileName));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Uploads given content to a file in the Microsoft OneDrive Cloud Storage.
        /// </summary>
        /// <param name="ll">current instance of List & Label</param>
        /// <param name="uploadParameters">requied parameters for Microsoft OneDrive OAuth 2.0 upload.</param>
        public static async void Upload(this Reporting.ListLabel ll, MicrosoftOneDriveUploadParameter uploadParameters)
        {
            var graphClient = AuthenticationHelper.GetAuthenticatedClient(uploadParameters.ApplicationId);

            if (graphClient != null)
            {
                var user = await graphClient.Me.Request().GetAsync();

                var uploadedItem = await graphClient
                                   .Drive
                                   .Root
                                   .ItemWithPath($"{uploadParameters.CloudPath}/{uploadParameters.CloudFileName}")
                                   .Content
                                   .Request()
                                   .PutAsync <DriveItem>(uploadParameters.UploadStream);
            }
        }