Upload to my_documents or my_photos folder OneDriv

2019-09-11 02:34发布

问题:

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