Upload to my_documents or my_photos folder OneDrive

回眸只為那壹抹淺笑 提交于 2020-01-06 19:51:58

问题


I can upload to the top level directory in OneDrive with a PUT request at the URI:

I can upload a specific folder if I know it's specific ID:

"https://apis.live.net/v5.0/folder.5f5fb682f4910ce0.5F5FB682F4910CE0!189/files/someFile.txt?access_token=xyz123"

But how do I upload to a folder using it's friendly name, e.g. my_photos. The OneDrive documentation isn't helpful - it seems to gloss over this. It mentions friendly names, but I don't know how to use them as part of a URI PUT request.

edit: https://msdn.microsoft.com/en-us/jj680723 shows using GETs with friendly names, but what about PUTs? I can't figure it out.

Thanks


回答1:


You should be able to upload to a 'special folder' by aiming your PUT at the same base URL you use for GETs, except with "/files" added on, like you do for normal folders. So: PUT https://apis.live.net/v5.0/skydrive/my_photos/files/foo.jpg

That said, we recommend you consider using the new OneDrive API instead. It is more powerful and better documented than the one you're using now. Here are the sections on special folders and uploading files. In the new API, the upload I mentioned above would look like PUT https://api.onedrive.com/v1.0/drive/special/photos:/foo.jpg



来源:https://stackoverflow.com/questions/31671280/upload-to-my-documents-or-my-photos-folder-onedrive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!