Skip to content

Commit

Permalink
Merge pull request #9644 from royalhuang/issue_9537
Browse files Browse the repository at this point in the history
feat: iOS重签名部分功能优化 #9537
  • Loading branch information
bkci-bot authored Nov 9, 2023
2 parents 9f3246e + afb8db4 commit b08f45f
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,20 @@ class DirectBkRepoClient {
path: String,
file: File,
metadata: Map<String, String> = mapOf(),
override: Boolean = true
override: Boolean = true,
headers: Map<String, String> = mapOf()
) {
logger.info("uploadLocalFile, userId: $userId, projectId: $projectId, repoName: $repoName, path: $path, " +
"file: ${file.canonicalPath}, metadata: $metadata, override: $override")
buildMetadataHeader(metadata)
val request = Request.Builder()
.url("${getBkRepoUrl()}/generic/$projectId/$repoName/${path.removePrefix("/")}")
.header(AUTHORIZATION, bkrepoAuth)
.header(BK_REPO_OVERRIDE, override.toString())
.header(BK_REPO_UID, userId)
.header(BK_REPO_METADATA, Base64.getEncoder().encodeToString(buildMetadataHeader(metadata).toByteArray()))
.put(RequestBody.create("application/octet-stream".toMediaTypeOrNull(), file))
.build()
OkhttpUtils.doHttp(request).use { response ->
headers.forEach { (key, value) -> request.header(key, value) }
OkhttpUtils.doHttp(request.build()).use { response ->
if (!response.isSuccessful) {
throw RemoteServiceException("upload file failed: ${response.body!!.string()}", response.code)
}
Expand All @@ -86,11 +86,11 @@ class DirectBkRepoClient {
path: String,
byteArray: ByteArray,
metadata: Map<String, String> = mapOf(),
override: Boolean = true
override: Boolean = true,
headers: Map<String, String> = mapOf()
): String {
logger.info("uploadByteArray, userId: $userId, projectId: $projectId, repoName: $repoName, path: $path, " +
"metadata: $metadata, override: $override")
buildMetadataHeader(metadata)
val url = "${getBkRepoUrl()}/generic/$projectId/$repoName/${path.removePrefix("/")}"
val request = Request.Builder()
.url(url)
Expand All @@ -99,8 +99,8 @@ class DirectBkRepoClient {
.header(BK_REPO_UID, userId)
.header(BK_REPO_METADATA, Base64.getEncoder().encodeToString(buildMetadataHeader(metadata).toByteArray()))
.put(RequestBody.create("application/octet-stream".toMediaTypeOrNull(), byteArray))
.build()
OkhttpUtils.doHttp(request).use { response ->
headers.forEach { (key, value) -> request.header(key, value) }
OkhttpUtils.doHttp(request.build()).use { response ->
if (!response.isSuccessful) {
throw RemoteServiceException("upload file failed: ${response.body!!.string()}", response.code)
}
Expand Down

0 comments on commit b08f45f

Please sign in to comment.