Skip to content

Commit

Permalink
fix: 修复DDC仓库接口未返回ContentType #2890
Browse files Browse the repository at this point in the history
* fix: 修复DDC仓库接口未返回ContentType #2890

* fix: 修复DDC仓库接口未返回ContentType #2890

* fix: 修复DDC仓库接口未返回ContentType #2890
  • Loading branch information
cnlkl authored Jan 2, 2025
1 parent b3334da commit d1a2388
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@

package com.tencent.bkrepo.ddc.artifact.repository

import com.tencent.bkrepo.common.api.constant.HttpHeaders
import com.tencent.bkrepo.common.api.constant.HttpStatus
import com.tencent.bkrepo.common.api.constant.MediaTypes
import com.tencent.bkrepo.common.api.constant.MediaTypes.APPLICATION_JSON
import com.tencent.bkrepo.common.api.exception.BadRequestException
import com.tencent.bkrepo.common.api.exception.ErrorCodeException
import com.tencent.bkrepo.common.api.message.CommonMessageCode
Expand Down Expand Up @@ -216,6 +218,7 @@ class DdcLocalRepository(
val artifactFile = context.getArtifactFile()
val repoDetail = context.repositoryDetail
val res = uploadReference(repoDetail, artifactInfo, artifactFile, context.userId).toJsonString()
HttpContextHolder.getResponse().setHeader(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON)
HttpContextHolder.getResponse().writer.println(res)
}

Expand Down Expand Up @@ -291,6 +294,7 @@ class DdcLocalRepository(
)
storageManager.storeArtifactFile(createRequest, getArtifactFile(), storageCredentials)
blobService.create(Blob.from(artifactInfo, getArtifactSha256(), getArtifactFile().getSize()))
HttpContextHolder.getResponse().setHeader(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON)
HttpContextHolder
.getResponse()
.writer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ package com.tencent.bkrepo.ddc.controller

import com.tencent.bkrepo.common.api.constant.HttpStatus
import com.tencent.bkrepo.common.service.util.HttpContextHolder
import com.tencent.bkrepo.ddc.controller.LegacyReferencesController.Companion.LEGACY_PREFIX
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RestController
import com.tencent.bkrepo.ddc.controller.LegacyReferencesController.Companion.LEGACY_PREFIX

@RestController
class HealthController {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@

package com.tencent.bkrepo.ddc.service

import com.tencent.bkrepo.common.api.constant.HttpHeaders
import com.tencent.bkrepo.common.api.constant.HttpStatus
import com.tencent.bkrepo.common.api.constant.HttpStatus.NOT_FOUND
import com.tencent.bkrepo.common.api.constant.MediaTypes.APPLICATION_JSON
import com.tencent.bkrepo.common.api.exception.BadRequestException
import com.tencent.bkrepo.common.api.exception.ErrorCodeException
import com.tencent.bkrepo.common.api.message.CommonMessageCode
Expand Down Expand Up @@ -102,6 +104,7 @@ class ReferenceArtifactService(
throw ErrorCodeException(ArtifactMessageCode.DIGEST_CHECK_FAILED, "blake3")
}
val res = referenceService.finalize(ref, ref.inlineBlob!!)
HttpContextHolder.getResponse().setHeader(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON)
HttpContextHolder.getResponse().writer.println(res.toJsonString())
}
}
Expand Down

0 comments on commit d1a2388

Please sign in to comment.