Skip to content

Instantly share code, notes, and snippets.

@hatsunea
Created November 24, 2024 08:24
Show Gist options
  • Save hatsunea/d78313e864085763f74953577f7f4314 to your computer and use it in GitHub Desktop.
Save hatsunea/d78313e864085763f74953577f7f4314 to your computer and use it in GitHub Desktop.
public async Task Verify()
{
var result = await PickAndShow(PickOptions.Default);
this.FileName = result.FullPath;
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.CacheControl = new CacheControlHeaderValue { NoCache = true, };
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", this.Token);
using (var multipartContent = new MultipartFormDataContent())
{
using (var fileContent = new StreamContent(File.OpenRead(this.FileName)))
{
fileContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "vein",
FileName = Path.GetFileName(this.FileName),
};
fileContent.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
multipartContent.Add(fileContent);
using (var response = await client.PostAsync(@"https://apigateway.research.global.fujitsu.com/vlcb/research/verify-match", multipartContent))
{
if (response.IsSuccessStatusCode)
{
// リクエストが成功した場合の処理
this.Response = "Success";
}
else
{
// リクエストが失敗した場合の処理
this.Response = response.StatusCode.ToString();
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment