【问题标题】:How to add binary data in microsoft graph api for uploading file using upload session如何在 microsoft graph api 中添加二进制数据以使用上传会话上传文件
【发布时间】:2020-03-19 13:30:45
【问题描述】:

对于我的 Flutter 项目,要在草稿电子邮件中上传附件,我创建了上传会话,并尝试通过该会话上传附件。为此,来自Microsoft graph official document 的大文件附件,需要这样传递:

PUT https://outlook.office.com/api/beta/Users('a8e8e219-4931-95c1-b73d-62626fd79c32@72aa88bf-76f0-494f-91ab-2d7cd730db47')/Messages('AAMkADI5MAAIT3drCAAA=')/AttachmentSessions('AAMkADI5MAAIT3k0tAAA=')?authtoken=eyJhbGciOiJSUzI1NiIsImtpZCI6IktmYUNIUlN6bllHMmNI
Content-Type: application/octet-stream
Content-Length: 2097152
Content-Range: bytes 0-2097151/3483322

{
  <bytes 0-2097151 of the file to be attached, in binary format>
}

谁能帮忙分享我们如何将二进制数据传递给请求?

【问题讨论】:

    标签: flutter microsoft-graph-api binary-data


    【解决方案1】:

    你可以试试下面的代码:

    $contentBytes = file_get_contents('image/image.jpg');
        $options = array(
            'http' => array(
                'method' => 'PUT',
                'header' => "Content-Type: application/octet-stream\r\nContent-Length:{$chunkSize}\r\nContent-Range: bytes {$startRange}- {$endRange}/{$fileSize}",
                'content' => $contentBytes,
            )
        );
            
            
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-30
      • 1970-01-01
      • 2021-02-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多