Skip to content

Commit

Permalink
fix stream for photos
Browse files Browse the repository at this point in the history
  • Loading branch information
damienbod committed Dec 2, 2023
1 parent e3479f2 commit 82ac952
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@ public async Task<string> GetGraphApiProfilePhoto(string oid)
var photo = string.Empty;
byte[] photoByte;

using (var photoStream = await _graphServiceClient.Users[oid]
.Photo
.Content
.GetAsync(b => b.Options.WithScopes("User.ReadBasic.All", "user.read")))
var streamPhoto = new MemoryStream();
using (var photoStream = await _graphServiceClient.Users[oid].Photo
.Content.GetAsync())
{
photoByte = ((MemoryStream)photoStream!).ToArray();
photoStream!.CopyTo(streamPhoto);
photoByte = streamPhoto!.ToArray();
}

using var imageFromFile = new MagickImage(photoByte);
// Sets the output format to jpeg
imageFromFile.Format = MagickFormat.Jpeg;
Expand Down

0 comments on commit 82ac952

Please sign in to comment.