首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >msgraph api中的附件大小错误

问msgraph api中的附件大小错误
EN

Stack Overflow用户
提问于 2020-10-26 20:25:03
回答 1查看 66关注 0票数 1

FileAttachment的属性大小大于binary的实际大小。

代码语言:javascript
复制
 {
    "@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代码:

代码语言:javascript
复制
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);
EN

回答 1

Stack Overflow用户

发布于 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对象,它特别有用。

考虑到他们谈论调制解调器,这有点过时了。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64537070

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档