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; }
}
/// <summary>
/// Get bytes from file
/// </summary>
/// <param name="path">path to file</param>
/// <param name="startByte">0 based position</param>
/// <param name="bytesToRead">Count of bytes to read</param>
/// <returns></returns>
public static string[] GetXData(string path, int startByte, int bytesToRead)
{
try
{
var header = new string[bytesToRead];
using var stream = File.OpenRead(path);
stream.Seek(startByte, SeekOrigin.Begin); // перемещаем указатель в позицию
// увеличиваем от 0 до длины буфера!!!
for (var i = 0; i < header.Length ; i++)
{
// когда читаем по байту сдвиг указателя происходит автоматически
header[i] = (stream.ReadByte().ToString("X2"));
}
return header;
}
catch (Exception e)
{
Console.WriteLine(e.Message);
return new string[0];
}
}
r = 'https://api.kuna.io/v3/auth/me'
api_path = "/v3/auth/me"
nonce = str(int(time.time()*1000.0))
body = str('')
msg = api_path+nonce+body
print(msg)
kun_signature = hmac.new(secret_key.encode('ascii'), msg.encode('ascii'), hashlib.sha384).hexdigest()
headers = {'accept': 'application/json',
'content-type': 'application/json',
'kun-nonce': nonce,
'kun-apikey': public_key,
'kun-signature': kun_signature}
pool = requests.post(r, headers=headers)
print(pool.text)
В то время как переменные принято именовать
public int myNumber = 1;
In addition to the rules, there are a number of identifier naming conventions used throughout the .NET APIs. By convention, C# programs use PascalCase for type names, namespaces, and all public members. In addition, the following conventions are common:
- Interface names start with a capital I.
- Attribute types end with the word Attribute.
- Enum types use a singular noun for non-flags, and a plural noun for flags.
- Identifiers should not contain two consecutive _ characters. Those names are reserved for compiler generated identifiers.
Please provide an email response specifically identifying the country in which the [Product Name] Software is developed and maintained.В письме укажите свою страну...
If the country of origin is outside the United States, please provide any information you may have stating that testing is performed in the United States prior to supplying products to customers....скажите, что вы никакого тестирования в США не проводили, а про других ничего не знаете...
Additionally, if available, please identify all authorized resellers of the product in question....поскольку ПО свободное, никто его не перепродаёт...
Lastly, please confirm that the product(s) in question is not manufactured by, contain critical components developed by, or receive substantial political or monetary influence from entities prohibited by Section 889 of the 2019 NDAA....никакую из перечисленных компаний вы не знаете и денег от них не получали.