Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

支持media服务 #2672

Merged
merged 2 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading