匿名上传到 OneDrive 上的公开共享文件夹 [英] Anonymously uploading to a publicly shared folder on OneDrive

查看:34
本文介绍了匿名上传到 OneDrive 上的公开共享文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

What is the REST API call to anonymously upload to a publicly shared folder on OneDrive?

我已尝试通过 OneDrive Web UI 创建链接属性为:拥有此链接的任何人都可以编辑此项目",并使用 REST API 共享文件夹:

I have tried sharing a folder both thru the OneDrive Web UI creating a link attributed with: "Anyone with this link can edit this item", and using the REST API:

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

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

In both cases, I can read from the shared folder without logging on by

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

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

I can also read the permission itself using

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
        }
    ]
}

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

However trying to upload a file or create a subfolder, i.e.

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": { }
}

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

both fail as unauthorized calls - but isn't the whole point of an "edit" link with "anonymous" scope that "anyone with this link can edit this item"?

我尝试了 https://graph.microsoft.com/v1.0 而不是 https://api.onedrive.com/v1.0/drives/{driveId} 而不是 /shares/{shareId} 以及 /shares/{shareToken},其中 shareToken 是权限中 linkwebUrl 的u!"编码.

I have tried various combinations of https://graph.microsoft.com/v1.0 instead of https://api.onedrive.com/v1.0 and /drives/{driveId} instead of /shares/{shareId} as well as /shares/{shareToken}, where shareToken is the "u!"-encoding of the webUrl from the link in the permission.

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

So far without being able to figure out the right REST API call. I hope someone is able to help :-)

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

You can download my TestOneDrive Visual Studio test project to reproduce the issues. It also contains initialization code to create and share the folder.

推荐答案

由于产品组没有人关注这个,也没有官方文档宣布这个,所以我建议你先在 UserVocie 或投票支持与您的问题接近的现有问题.

Due to no guys from Product Group following this and no official docs announced this, so I suggest you to submit an feature request first on UserVocie or vote up an existing one close to your issue.

这篇关于匿名上传到 OneDrive 上的公开共享文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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