FileAttachment的属性大小大于binary的实际大小。
{
"@odata.type": "#microsoft.graph.fileAttachment",
"@odata.mediaContentType": "application/octet-stream",
"id": "<the attachment id>",
"lastModifiedDateTime": "2020-10-26T09:57:36Z",
"name": "test.bin",
"contentType": "application/octet-stream",
"size": 245,
"isInline": false,
"contentId": null,
"contentLocation": null,
"contentBytes": "aGVsbG8gd29ybGQ="
}下面是在json data上创建的一段java代码:
IGraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider(provider).buildClient();
FileAttachment attachment = new FileAttachment();
attachment.oDataType = "#microsoft.graph.fileAttachment";
attachment.name = "test.bin";
attachment.contentBytes = "hello world".getBytes();
Attachment att = graphClient.users().byId(userId).messages().byId(mailId).attachments().buildRequest().post(attachment);
System.out.println(att.size);发布于 2020-10-28 10:23:11
图表中的附件大小应该只是PidTagAttachSize属性https://docs.microsoft.com/en-us/openspecs/exchange_server_protocols/ms-oxprops/917d8d18-adee-4f14-9f2a-9a1d37fff41e。返回的大小基本上由attachment对象中所有附件属性的大小(而不仅仅是底层附件大小)组成。因此,它将始终大于实际附件大小。还有另一种描述https://docs.microsoft.com/en-us/office/client-developer/outlook/mapi/pidtagattachsize-canonical-property
此属性可用于在通过调制解调器执行远程传输之前检查附件的大致大小,并在将附件保存到磁盘时显示进度指示器。对于附着的OLE对象,它特别有用。
考虑到他们谈论调制解调器,这有点过时了。
https://stackoverflow.com/questions/64537070
复制相似问题