Large (> 4mb) File Attachments

2019-04-11 13:29发布

问题:

Using the Microsoft Graph API, it is possible to add file attachments to messages as described here. However, since REST requests have a total size limit of 4mb this does not allow for very large attachments.

A resumable upload session allows for larger uploads that may be referenced by reference attachments providing a download link. However, these links are obviously short-lived and we would like to clean up the files at some point.

Is there any way to create a message with persistent file attachments larger than 4mb? Thinking along the lines of a DriveItem->FileAttachment conversion here, but could not find anything on the topic. Help is very much appreciated!

回答1:

As of May 2017 you can use the referenceAttachment resource type. This allows you to attach a DriveItem from the OneDrive to a message:

POST https://graph.microsoft.com/beta/me/messages/AAMkAGE1M88AADUv0uFAAA=/attachments
Content-type: application/json
Content-length: 319

{ 
    "@odata.type": "#microsoft.graph.referenceAttachment", 
    "name": "Personal pictures", 
    "sourceUrl": "https://contoso.com/personal/mario_contoso_net/Documents/Pics", 
    "providerType": "oneDriveConsumer", 
    "permission": "Edit", 
    "isFolder": "True" 
}