public async Task <Stream> GetOneDriveContentsAsStreamAsync(OneDriveAttribute attr, CancellationToken token) { IGraphServiceClient client = await _clientProvider.GetMSGraphClientFromTokenAttributeAsync(attr, token); Stream response; // How to download from OneDrive: https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/item_downloadcontent // GET https://graph.microsoft.com/v1.0/me/drive/root:/test1/hi.txt:/content HTTP/1.1 bool isShare = attr.Path.StartsWith("https://"); if (isShare) { // TODO: Move this to GraphServiceClient // Download via a Share URL var shareToken = UrlToSharingToken(attr.Path); response = await client.GetOneDriveContentStreamFromShareAsync(shareToken, token); } else { try { // Retrieve stream of OneDrive item response = await client.GetOneDriveContentStreamAsync(attr.Path, token); } catch { //File does not exist, so create new memory stream response = new MemoryStream(); } } return(ConvertStream(response, attr, client)); }
public async Task SendMessageAsync(OutlookAttribute attr, Message msg, CancellationToken token) { IGraphServiceClient client = await _clientManager.GetMSGraphClientFromTokenAttributeAsync(attr, token); await client.SendMessageAsync(msg, token); }
internal async Task <WorkbookTable> GetExcelTableAsync(ExcelAttribute attr, CancellationToken token) { IGraphServiceClient client = await _clientProvider.GetMSGraphClientFromTokenAttributeAsync(attr, token); return(await client.GetTableWorkbookAsync(attr.Path, attr.TableName, token)); }