Upload Box Api with Unity
Hi,
I am having issue for uploading a file on BOX with box api
Please see below code snippet for C# to upload a file on box.
var client = new HttpClient();
var content = new MultipartFormDataContent();
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + Utils.GetAccessTokenFromFile());
content.Add(new StreamContent(File.Open(Utils.AnyFilePath, FileMode.Open)), "token", "test.txt");
content.Add(new StringContent("{\"name\":\"test.txt\", \"parent\":{\"id\":\"0\"}}"), "attributes");
var result = await client.PostAsync("https://upload.box.com/api/2.0/files/content", content);
result.EnsureSuccessStatusCode();
string sContent = await result.Content.ReadAsStringAsync();
I tried many ways In Unity to upload a file the same manner with multiform data. However, no success. How can we make the same request from Unity ?
Any ideas ?
Thank you in advance.
投稿コメントは受け付けていません。
コメント
0件のコメント