upload_url = r.json()['response']['upload_url']
k = requests.post(upload_url, files={'file': open('1.mp4', 'rb')})
using System;
using System.IO;
using System.Net.Http;
using System.Text.Json;
using System.Text.Json.Serialization;
using var httpClient = new HttpClient();
// Как-то получаем upload_url
var r = @"{
""response"": {
""upload_url"": ""/something""
}
";
var response = JsonSerializer.Deserialize<Response>(r);
var uploadUrl = response!.ResponseData.UploadUrl;
using var fileStream = File.OpenRead("./file.mp4");
using var request = new HttpRequestMessage
{
RequestUri = new Uri(uploadUrl),
Method = HttpMethod.Post,
Content = new MultipartFormDataContent
{
{
new StreamContent(fileStream), "file", "file.mp4"
}
}
};
httpClient.Send(request);
class Response
{
[JsonPropertyName("response")] public ResponseData ResponseData { get; set; }
}
class ResponseData
{
[JsonPropertyName("upload_url")] public string UploadUrl { get; set; }
}