[英]OneDrive API integration with Unity 3D
I would like to know if it is possible to integrate the OneDrive API directly with Unity 3D.我想知道是否可以将 OneDrive API 直接与 Unity 3D 集成。 I am trying to upload image files to an OneDrive account using C#, yet Microsoft's documentation does not mention how to achieve this.
我正在尝试使用 C# 将图像文件上传到 OneDrive 帐户,但 Microsoft 的文档没有提到如何实现这一点。
One drive only provides REST API which you can use with Web Requests一个驱动器仅提供可用于Web 请求的REST API
Assuming you are logged in and you have a session token and key and OneDrive URL from API you can use PUT request: PUT /drives/{drive-id}/items/{parent-id}:/{filename}:/content
to upload image假设您已登录并且您有来自 API 的会话令牌和密钥以及 OneDrive URL,您可以使用 PUT 请求:
PUT /drives/{drive-id}/items/{parent-id}:/{filename}:/content
上传图片
void Start() {
StartCoroutine(Upload());
}
IEnumerator Upload() {
byte[] myData = System.Text.Encoding.UTF8.GetBytes("This is some test data");
UnityWebRequest www = UnityWebRequest.Put("ttps://api.onedrive.com/v1.0/drives/{drive-id}/items/{parent-id}:/{filename}:/content", myData);
//add to www object all header data with session token and content type
yield return www.SendWebRequest();
if(www.isNetworkError || www.isHttpError) {
Debug.Log(www.error);
}
else {
Debug.Log("Upload complete!");
}
}
You can also try community made C# plugins for that like this one: https://github.com/OneDrive/onedrive-sdk-csharp but they did not publish a change for a 3 years now, so it might now work anymore您还可以尝试社区制作的 C# 插件,例如: https : //github.com/OneDrive/onedrive-sdk-csharp但他们现在已经 3 年没有发布更改了,所以它现在可能不再起作用了
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.