匿名上传到OneDrive上的公共共享文件夹 [英] Anonymously uploading to a publicly shared folder on OneDrive
问题描述
匿名上传到OneDrive上的公共共享文件夹的REST API调用是什么?
我尝试通过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}
的各种组合,其中shareToken
是webUrl
的"u!"编码在许可中的link
中.
到目前为止,还无法找出正确的REST API调用.我希望有人能够提供帮助:-)
您可以下载我的 TestOneDrive Visual Studio测试项目来重现问题.它还包含用于创建和共享文件夹的初始化代码.
由于此后产品小组中没有人员,也没有正式的文档宣布,因此建议您先在 In both cases, I can read from the shared folder without logging on by I can also read the permission itself using => However trying to upload a file or create a subfolder, i.e. or 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"? I have tried various combinations of So far without being able to figure out the right REST API call. I hope someone is able to help :-) You can download my TestOneDrive Visual Studio test project to reproduce the issues. It also contains initialization code to create and share the folder. 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屋!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
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.