我的问题是,当我通过GUI查看文件时,我得到以下消息:
Client did not publish a checksum value. If you trust the uploaded
artifact you can accept the actual checksum by clicking the ‘Fix
Checksum’ button.
如何修复上传以使此消息消失?
如果我通过GUI上传文件,我不提供校验和值,那么为什么我在使用API时必须这样做呢?在使用API修复校验和时,我可以调用额外的函数吗?
我也看到了这个设置:https://www.jfrog.com/confluence/display/RTF20/Handling+Checksums
这可能与我的问题有关吗?
string inFilePath = @"C:\temp\file.ext"; string inUrl = @"domain.com/repoKey/"; string username = "username"; string apiKey = "apikey"; using (HttpClient client = new HttpClient()) { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic",Convert.ToBase64String(Encoding.ASCII.GetBytes(username+":"+apiKey))); using (var stream = File.OpenRead(inFilePath)) { var response = client.PutAsync(inUrl + stream.Name,new StreamContent(stream)); using (HttpContent content = response.Result.Content) { string data = content.ReadAsstringAsync().Result; } } }
更新
有三种类型的校验和和两组校验和组.
"checksums" : { "sha1" : "94332c090bdcdd87bd86426c224bcc7dc1c5f784","md5" : "dcada413214a5bd7164c6961863f5111","sha256" : "049c671f48e94c1ad25500f64e4879312cae70f489edc21313334b3f77b631e6" },"originalChecksums" : { "sha1" : "94332c090bdcdd87bd86426c224bcc7dc1c5f784","md5" : "dcada413214a5bd7164c6961863f5111" }
校验和 – 由Artifactory计算
originalChecksums – 是上传者提供的
当我使用API时,originalChecksums组是空的,我认为这会呈现上面的消息.
解决方法
所以在digging之后,你似乎需要:
>计算客户端的校验和(sha1)
>在PUT请求中提供每个校验和作为HTTP标头
对于您的C#示例,正确的解决方案是使用计算的校验和添加标题“X-Checksum-Sha1”.
如链接文档中所述,一个简单的卷曲示例是
curl -uadmin:password -T file.jar -H "X-Checksum-Sha1:c9a355147857198da3bdb3f24c4e90bd98a61e8b""http://localhost:8081/artifactory/libs-release-local/file.jar" -i
对于artifactory-client-java用户,简单的解决方法是添加到文档化的上传示例中:
java.io.File file = new java.io.File("filetoUpload.txt"); File result = artifactory.repository("RepoName").upload("path/to/newName.txt",file).doUpload();
另一个中间呼叫:bySha1Checksum():
java.io.File file = new java.io.File("filetoUpload.txt"); File result = artifactory.repository("RepoName").upload("path/to/newName.txt",file).bySha1Checksum().doUpload();
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。