Okay,
Well, I'm trying to figure out how to do this.
I've ready the API and and yet this never works.
using (HttpClient client = new HttpClient())
{
if (!path.EndsWith("/")) path = $"{path}/";
string url = config.CreateRequest(client, null, $"{path}{file.Name}");
string sha1 = JFrogLoader.GetSha1Hash(file);
string sha256 = JFrogLoader.GetSha256Hash(file);
string md5 = JFrogLoader.GetMD5Hash(file);
using (Stream stream = file.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
StreamContent content = new StreamContent(stream);
client.DefaultRequestHeaders.Add("X-Checksum-Deploy", "true");
client.DefaultRequestHeaders.Add("X-Checksum-Sha1", sha1);
client.DefaultRequestHeaders.Add("X-Checksum-Sha256", sha256);
client.DefaultRequestHeaders.Add("X-Checksum", md5);
content.Headers.Add("Content-Type", "application/octet-stream");
HttpResponseMessage message = await client.PutAsync(url, content);
string response = await message.Content.ReadAsStringAsync();
return message.StatusCode == System.Net.HttpStatusCode.Created;
}
}
The thing is, if I don't use any of the "X-Checksum-"
header items, the deploy works, but when you navigate to the page in Artifactory, it has the "Fix Checksum" button. So I figured I should probably provide them.
My methods that generate the checksums use the "*CryptoServiceProvider" classes, and trim the final '=' from the computed hash string. But every time I add in the checksum headers, I get a multi-part exception for "Unable to read data from the transport connection : An existing connection was forcibly closed by the remote host".
I've tried using the content.Headers
and client.DefaultRequestHeaders
.
I've tried only providing the SHa1
.
I've tried naming the md5
X-Checksum-Md5
(which is not in the api, but figured it was worth a shot).
Nothing works, and i get a connection closed by host.
Any ideas how I should resolve this? Thanks in advance.