Microsoft Graph:将文件上传到共享库而不是用户的库? [英] Microsoft Graph: Uploading files to shared library instead of user's library?

查看:191
本文介绍了Microsoft Graph:将文件上传到共享库而不是用户的库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在有关上传,列出了这些请求选项:

In the documentation about Upload, these request options are listed:

PUT /me/drive/items/{parent-id}:/{filename}:/content
PUT /me/drive/root:/{parent-path}/{filename}:/content
PUT /me/drive/items/{parent-id}/children/{filename}/content
PUT /groups/<id>/drive/items/<parent-id>/children/<filename>/content

在有关可恢复上传的文档中,创建一个上传会话,显示以下选项:

In the documentation about Resumable Uploads, Create an upload session show these options:

POST /me/drive/root:/{path-to-item}:/createUploadSession
POST /me/drive/items/{parent-item-id}:/{filename}:/createUploadSession

如果我必须上传到其他(不是我")驱动器,该怎么办?例如,默认共享库( https://mycompany.sharepoint.com/Shared%20Documents),对于除上传以外的任何其他海豚,文档说可以按以下方式访问:

What if I have to upload to other (not 'me') drive? For example, the default shared library (https://mycompany.sharepoint.com/Shared%20Documents), which for any other porpoise besides uploading, the documentation says can be accessed like this:

/drives/{drive-id}/items/{item-id}

所以,我的问题是:是否可以上传到"/Shared Documents"?如果是这样,那么PUT(小文件)或POST(上传会话)的正确语法是什么? 也许与此类似? (我只是弥补了这一点,所以不起作用)

So, my question is: Is it possible to upload to "/Shared Documents"? If so, which is the right syntax for the PUT (small file) or POST (upload session)? Perhaps something similar to this? (I just made this up, and it doesn't work)

PUT /drives/{drive-id}/items/{parent-id}/{filename}:/content

或(如果是上载会话):

or (in case of an upload session):

POST /drives/{drive-id}/items/{parent-item-id}:/{filename}:/createUploadSession

例如,在图形资源管理器中,响应类似这个:

For example, in the Graph Explorer, the response for something like this:

/v1.0/drives/THEDRIVEID/items/THEFOLDERID:/whatever.jpg:/createUploadSession

是:

{
    "error": {
        "code": "invalidRequest",
        "message": "A valid path must be provided.",
        "innerError": {
            "request-id": "THERETURNEDID",
            "date": "THERETURNEDDATE"
        }
    }
}

因为也可以通过/drive/root/访问公司的根目录,所以我也尝试过(在1.0和beta中都没有运气):

Because the company's root can also be accessed as /drive/root/, I also tried (with no luck, in both 1.0 and beta):

/drive/root:/whatever.jpg:/createUploadSession
/drive/root/whatever.jpg:/createUploadSession

推荐答案

这是可能的,但是您需要正确的应用程序权限才能读取/创建用户OneDrive之外的文件.而不是请求Files.ReadWrite,您需要请求Sites.ReadWrite.All,然后使用/v1.0/drive/root:/file.bin:/createUploadSession.

This is possible, but you need the right app permissions to be able to read/create files outside of the user's OneDrive. Instead of requesting Files.ReadWrite, you would need to request Sites.ReadWrite.All and then use /v1.0/drive/root:/file.bin:/createUploadSession.

您还可以使用 SharePoint网站API 在Microsoft Graph中访问团队站点文档库(而不是根站点).但是,此API仍处于beta版本,不应在生产应用中使用.

You can also use the SharePoint Sites API in Microsoft Graph to access team site document libraries (other than the root site). However, this API is still in the beta version and should not be used in production apps.

这篇关于Microsoft Graph:将文件上传到共享库而不是用户的库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆