【问题标题】:Anonymously uploading to a publicly shared folder on OneDrive匿名上传到 OneDrive 上的公开共享文件夹
【发布时间】:2018-09-05 13:36:52
【问题描述】:

什么是 REST API 调用以匿名上传到 OneDrive 上的公共共享文件夹?

我尝试通过 OneDrive Web UI 创建一个链接并使用 REST API 共享一个文件夹:“任何拥有此链接的人都可以编辑此项目”:

POST https://graph.microsoft.com/v1.0/drives/{driveId}/items/{sharedFolderId}/createLink
Content-type: application/json
{
    "type": "edit",
    "scope": "anonymous"
}

在这两种情况下,我都可以在不登录的情况下从共享文件夹中读取

GET https://api.onedrive.com/v1.0/shares/{shareId}/items/{sharedFolderId}

我也可以使用读取权限本身

GET https://api.onedrive.com/v1.0/shares/{shareId}/items/{sharedFolderId}/permissions

=>

{
    "@odata.context":"https://api.onedrive.com/v1.0/$metadata#shares('{shareId}')/items('{sharedFolderId')/permissions",
    "value":
    [
        {
            "id":"{permissionId}",
            "link":
            {
                "application":
                {
                    "displayName":"{my own app}",
                    "id":"{short app id}"
                },
                "type":"edit",
                "webUrl":"https://1drv.ms/u/{shareId}"
            },
            "roles":["write"],
            "shareId":"{shareId}",
            "expirationDateTime":"0001-01-01T00:00:00Z",
            "hasPassword":false
        }
    ]
}

但是尝试上传文件或创建子文件夹,即

PUT https://api.onedrive.com/v1.0/shares/{shareId}/driveItem:/{filename}:/content
Content-type: text/plain
some text goes here

POST https://api.onedrive.com/v1.0/shares/{shareId}/items/{sharedFolderId}/children
Content-type: application/json
{
    "name": "TestFolder",
    "folder": { }
}

两者都因未经授权的调用而失败 - 但具有“匿名”范围的“编辑”链接的全部意义不在于“任何拥有此链接的人都可以编辑此项目”吗?

我尝试了https://graph.microsoft.com/v1.0 的各种组合而不是https://api.onedrive.com/v1.0/drives/{driveId} 而不是/shares/{shareId} 以及/shares/{shareToken},其中shareTokenwebUrl 的“u!”编码来自权限中的link

到目前为止,还无法找出正确的 REST API 调用。我希望有人能够提供帮助:-)

您可以下载我的TestOneDrive Visual Studio 测试项目来重现这些问题。它还包含创建和共享文件夹的初始化代码。

【问题讨论】:

  • 我认为这是设计使然。您可以在用户语音上提交功能请求。
  • 好吧,如果这是设计使然,我希望 createLink{ "type": "edit", "scope": "anonymous" } 的请求无法开始。有谁知道 OneDrive 是否支持匿名上传到公共共享文件夹?

标签: microsoft-graph-api onedrive


【解决方案1】:

由于产品组中没有人关注此内容,也没有官方文档宣布此内容,因此我建议您先在 UserVocie 上提交功能请求,或者对与您的问题接近的现有请求进行投票。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-01-27
  • 2018-05-03
  • 1970-01-01
  • 2011-10-01
  • 1970-01-01
相关资源
最近更新 更多