Skip to content

Commit

Permalink
feat : 支持media服务 #2672
Browse files Browse the repository at this point in the history
* bug: media服务权限认证失败 #2616

* feat: 转码视频支持保留元数据 #2598
  • Loading branch information
felixncheng authored Oct 23, 2024
1 parent 0ee1bbc commit 3b80fdb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.RequestBody.Companion.toRequestBody
import org.slf4j.LoggerFactory
import org.springframework.web.context.request.RequestContextHolder
import java.io.IOException
import java.util.concurrent.TimeUnit

Expand Down Expand Up @@ -360,9 +361,11 @@ open class PermissionManager(
path = paths?.first(),
)
// devx 是否需要auth 校验仓库维度的访问黑名单
val devxAccessFrom = HttpContextHolder.getRequest().getAttribute(HEADER_DEVX_ACCESS_FROM)
if (devxAccessFrom == DEVX_ACCESS_FROM_OFFICE) {
checkRequest.requestSource = DEVX_ACCESS_FROM_OFFICE
if (RequestContextHolder.getRequestAttributes() != null) {
val devxAccessFrom = HttpContextHolder.getRequest().getAttribute(HEADER_DEVX_ACCESS_FROM)
if (devxAccessFrom == DEVX_ACCESS_FROM_OFFICE) {
checkRequest.requestSource = DEVX_ACCESS_FROM_OFFICE
}
}
if (checkPermissionFromAuthService(checkRequest) != true) {
// 无权限,响应403错误
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,20 @@ import com.tencent.bkrepo.media.config.MediaProperties
import com.tencent.bkrepo.media.stream.TranscodeParam
import com.tencent.bkrepo.media.stream.TranscodeConfig
import com.tencent.bkrepo.media.stream.TranscodeHelper
import com.tencent.bkrepo.repository.api.MetadataClient
import com.tencent.bkrepo.repository.pojo.metadata.MetadataSaveRequest
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Service

/**
* 视频转码服务
* */
@Service
class TranscodeService(private val tokenService: TokenService, private val mediaProperties: MediaProperties) :
class TranscodeService(
private val tokenService: TokenService,
private val mediaProperties: MediaProperties,
private val metadataClient: MetadataClient,
) :
ArtifactService() {

/**
Expand Down Expand Up @@ -63,6 +69,13 @@ class TranscodeService(private val tokenService: TokenService, private val media
val context = ArtifactUploadContext(repo, newArtifactFile, newArtifactInfo)
repository.upload(context)
logger.info("Upload new file[$newArtifactInfo]")
// 复制原有视频的metadata
val originMetadata =
metadataClient.listMetadata(projectId, repoName, originArtifactInfo.getArtifactFullPath()).data
originMetadata?.let {
val copyRequest = MetadataSaveRequest(projectId, repoName, newArtifactInfo.getArtifactFullPath(), it)
metadataClient.saveMetadata(copyRequest)
}
val removeContext = ArtifactRemoveContext(repo, originArtifactInfo)
repository.remove(removeContext)
logger.info("Delete origin file[$originArtifactInfo]")
Expand Down

0 comments on commit 3b80fdb

Please sign in to comment.