如何从 Microsoft Graph SDK 获取用户图像
How to get User Image from Microsoft Graph SDK
我正在尝试从 Microsoft Graph SDK 获取图像的二进制值,这是我的代码和响应
var userRequest = graphClient.Users[{id}].Photo
.Request();
var user = await userRequest.GetAsync();
回复:
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#users('userId')/photo/$entity",
"@odata.mediaContentType": "image/Jpeg",
"width": 503,
"height": 626,
"id": "503X626"
}
关于如何获取特定尺寸图像值的任何建议。
经过长时间的寻找我找到了路
//get the photo
var requestUserPhoto = graphClient.Users[{id}].Photo.Request();
var resultsUserPhoto = requestUserPhoto.GetAsync().Result;
//create the file
var profilePhotoNamePath = "Images/" + {id}+ ".jpeg";
// get user photo content
var requestUserPhotoFile =
graphClient.Users[{id}].Photos["64x64"].Content.Request();
var resultsUserPhotoFile = requestUserPhotoFile.GetAsync().Result;
// create the image
var profilePhoto = System.IO.File.Create(profilePhotoNamePath);
resultsUserPhotoFile.Seek(0, System.IO.SeekOrigin.Begin);
resultsUserPhotoFile.CopyTo(profilePhoto);
我正在尝试从 Microsoft Graph SDK 获取图像的二进制值,这是我的代码和响应
var userRequest = graphClient.Users[{id}].Photo
.Request();
var user = await userRequest.GetAsync();
回复:
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#users('userId')/photo/$entity",
"@odata.mediaContentType": "image/Jpeg",
"width": 503,
"height": 626,
"id": "503X626"
}
关于如何获取特定尺寸图像值的任何建议。
经过长时间的寻找我找到了路
//get the photo
var requestUserPhoto = graphClient.Users[{id}].Photo.Request();
var resultsUserPhoto = requestUserPhoto.GetAsync().Result;
//create the file
var profilePhotoNamePath = "Images/" + {id}+ ".jpeg";
// get user photo content
var requestUserPhotoFile =
graphClient.Users[{id}].Photos["64x64"].Content.Request();
var resultsUserPhotoFile = requestUserPhotoFile.GetAsync().Result;
// create the image
var profilePhoto = System.IO.File.Create(profilePhotoNamePath);
resultsUserPhotoFile.Seek(0, System.IO.SeekOrigin.Begin);
resultsUserPhotoFile.CopyTo(profilePhoto);