diff --git a/src/backend/ci/core/artifactory/api-artifactory/src/main/kotlin/com/tencent/devops/artifactory/api/service/ServiceFileResource.kt b/src/backend/ci/core/artifactory/api-artifactory/src/main/kotlin/com/tencent/devops/artifactory/api/service/ServiceFileResource.kt index 8ceee0edd3e..b60ba3a4065 100644 --- a/src/backend/ci/core/artifactory/api-artifactory/src/main/kotlin/com/tencent/devops/artifactory/api/service/ServiceFileResource.kt +++ b/src/backend/ci/core/artifactory/api-artifactory/src/main/kotlin/com/tencent/devops/artifactory/api/service/ServiceFileResource.kt @@ -75,7 +75,10 @@ interface ServiceFileResource { projectCode: String? = null, @ApiParam("渠道类型", required = true) @QueryParam("fileChannelType") - fileChannelType: FileChannelTypeEnum = FileChannelTypeEnum.SERVICE + fileChannelType: FileChannelTypeEnum = FileChannelTypeEnum.SERVICE, + @ApiParam("是否为插件logo", required = false) + @QueryParam("logo") + logo: Boolean? = false ): Result @ApiOperation("下载文件") diff --git a/src/backend/ci/core/artifactory/biz-artifactory-sample/src/main/kotlin/com/tencent/devops/artifactory/resources/UserFileResourceImpl.kt b/src/backend/ci/core/artifactory/biz-artifactory-sample/src/main/kotlin/com/tencent/devops/artifactory/resources/UserFileResourceImpl.kt index 506545c47ac..c67eb732257 100644 --- a/src/backend/ci/core/artifactory/biz-artifactory-sample/src/main/kotlin/com/tencent/devops/artifactory/resources/UserFileResourceImpl.kt +++ b/src/backend/ci/core/artifactory/biz-artifactory-sample/src/main/kotlin/com/tencent/devops/artifactory/resources/UserFileResourceImpl.kt @@ -70,10 +70,10 @@ class UserFileResourceImpl @Autowired constructor( checkParam(userId, projectId, path) val url = archiveFileService.uploadFile( userId = userId, - projectId = projectId, - filePath = path, inputStream = inputStream, disposition = disposition, + projectId = projectId, + filePath = path, fileType = FileTypeEnum.BK_CUSTOM, fileChannelType = FileChannelTypeEnum.WEB_SHOW ) diff --git a/src/backend/ci/core/artifactory/biz-artifactory/src/main/kotlin/com/tencent/devops/artifactory/resources/ServiceFileResourceImpl.kt b/src/backend/ci/core/artifactory/biz-artifactory/src/main/kotlin/com/tencent/devops/artifactory/resources/ServiceFileResourceImpl.kt index a5e9144aa49..57890f6396d 100644 --- a/src/backend/ci/core/artifactory/biz-artifactory/src/main/kotlin/com/tencent/devops/artifactory/resources/ServiceFileResourceImpl.kt +++ b/src/backend/ci/core/artifactory/biz-artifactory/src/main/kotlin/com/tencent/devops/artifactory/resources/ServiceFileResourceImpl.kt @@ -46,14 +46,16 @@ class ServiceFileResourceImpl @Autowired constructor(private val archiveFileServ inputStream: InputStream, disposition: FormDataContentDisposition, projectCode: String?, - fileChannelType: FileChannelTypeEnum + fileChannelType: FileChannelTypeEnum, + logo: Boolean? ): Result { val url = archiveFileService.uploadFile( userId = userId, inputStream = inputStream, disposition = disposition, projectId = projectCode, - fileChannelType = fileChannelType + fileChannelType = fileChannelType, + logo = logo ) return Result(url) } diff --git a/src/backend/ci/core/artifactory/biz-artifactory/src/main/kotlin/com/tencent/devops/artifactory/service/ArchiveFileService.kt b/src/backend/ci/core/artifactory/biz-artifactory/src/main/kotlin/com/tencent/devops/artifactory/service/ArchiveFileService.kt index 9918ac539f3..53c71592065 100644 --- a/src/backend/ci/core/artifactory/biz-artifactory/src/main/kotlin/com/tencent/devops/artifactory/service/ArchiveFileService.kt +++ b/src/backend/ci/core/artifactory/biz-artifactory/src/main/kotlin/com/tencent/devops/artifactory/service/ArchiveFileService.kt @@ -60,7 +60,8 @@ interface ArchiveFileService { fileName: String? = null, fileType: FileTypeEnum? = null, props: Map? = null, - fileChannelType: FileChannelTypeEnum + fileChannelType: FileChannelTypeEnum, + logo: Boolean? = false ): String /** @@ -74,7 +75,8 @@ interface ArchiveFileService { filePath: String? = null, fileType: FileTypeEnum? = null, props: Map? = null, - fileChannelType: FileChannelTypeEnum + fileChannelType: FileChannelTypeEnum, + logo: Boolean? = false ): String /** diff --git a/src/backend/ci/core/artifactory/biz-artifactory/src/main/kotlin/com/tencent/devops/artifactory/service/impl/ArchiveFileServiceImpl.kt b/src/backend/ci/core/artifactory/biz-artifactory/src/main/kotlin/com/tencent/devops/artifactory/service/impl/ArchiveFileServiceImpl.kt index bb942893a9b..e27d88d0fe4 100644 --- a/src/backend/ci/core/artifactory/biz-artifactory/src/main/kotlin/com/tencent/devops/artifactory/service/impl/ArchiveFileServiceImpl.kt +++ b/src/backend/ci/core/artifactory/biz-artifactory/src/main/kotlin/com/tencent/devops/artifactory/service/impl/ArchiveFileServiceImpl.kt @@ -79,7 +79,8 @@ abstract class ArchiveFileServiceImpl : ArchiveFileService { filePath: String?, fileType: FileTypeEnum?, props: Map?, - fileChannelType: FileChannelTypeEnum + fileChannelType: FileChannelTypeEnum, + logo: Boolean? ): String { val fileName = String(disposition.fileName.toByteArray(Charset.forName("ISO8859-1")), Charset.forName("UTF-8")) val file = DefaultPathUtils.randomFile(fileName) @@ -93,7 +94,8 @@ abstract class ArchiveFileServiceImpl : ArchiveFileService { fileName = fileName, fileType = fileType, props = props, - fileChannelType = fileChannelType + fileChannelType = fileChannelType, + logo = logo ) } finally { file.delete() diff --git a/src/backend/ci/core/artifactory/biz-artifactory/src/main/kotlin/com/tencent/devops/artifactory/service/impl/BkRepoArchiveFileServiceImpl.kt b/src/backend/ci/core/artifactory/biz-artifactory/src/main/kotlin/com/tencent/devops/artifactory/service/impl/BkRepoArchiveFileServiceImpl.kt index 1750c8c9bc1..6bb1ac4c2a0 100644 --- a/src/backend/ci/core/artifactory/biz-artifactory/src/main/kotlin/com/tencent/devops/artifactory/service/impl/BkRepoArchiveFileServiceImpl.kt +++ b/src/backend/ci/core/artifactory/biz-artifactory/src/main/kotlin/com/tencent/devops/artifactory/service/impl/BkRepoArchiveFileServiceImpl.kt @@ -88,7 +88,8 @@ class BkRepoArchiveFileServiceImpl @Autowired constructor( fileName: String?, fileType: FileTypeEnum?, props: Map?, - fileChannelType: FileChannelTypeEnum + fileChannelType: FileChannelTypeEnum, + logo: Boolean? ): String { val destPath = filePath ?: DefaultPathUtils.randomFileName() val metadata = mutableMapOf() @@ -102,8 +103,20 @@ class BkRepoArchiveFileServiceImpl @Autowired constructor( projectId!! } val repoName = BkRepoUtils.getRepoName(fileType) - defaultBkRepoClient.uploadLocalFile(userId, repoProjectId, repoName, destPath, file, metadata) - return generateFileDownloadUrl(fileChannelType, "$repoProjectId/$repoName/$destPath") + return if (logo == true) { + defaultBkRepoClient.uploadLocalFile( + userId = userId, + projectId = BKREPO_STORE_PROJECT_ID, + repoName = REPO_NAME_STATIC, + path = destPath, + file = file, + metadata = metadata + ) + generateFileDownloadUrl(fileChannelType, destPath).plus("?logo=true") + } else { + defaultBkRepoClient.uploadLocalFile(userId, repoProjectId, repoName, destPath, file, metadata) + generateFileDownloadUrl(fileChannelType, "$repoProjectId/$repoName/$destPath") + } } override fun downloadArchiveFile( diff --git a/src/backend/ci/core/artifactory/biz-artifactory/src/main/kotlin/com/tencent/devops/artifactory/service/impl/DiskArchiveFileServiceImpl.kt b/src/backend/ci/core/artifactory/biz-artifactory/src/main/kotlin/com/tencent/devops/artifactory/service/impl/DiskArchiveFileServiceImpl.kt index fc4cf3457e1..b2e325a67c6 100644 --- a/src/backend/ci/core/artifactory/biz-artifactory/src/main/kotlin/com/tencent/devops/artifactory/service/impl/DiskArchiveFileServiceImpl.kt +++ b/src/backend/ci/core/artifactory/biz-artifactory/src/main/kotlin/com/tencent/devops/artifactory/service/impl/DiskArchiveFileServiceImpl.kt @@ -353,7 +353,8 @@ class DiskArchiveFileServiceImpl : ArchiveFileServiceImpl() { fileName: String?, fileType: FileTypeEnum?, props: Map?, - fileChannelType: FileChannelTypeEnum + fileChannelType: FileChannelTypeEnum, + logo: Boolean? ): String { logger.info("uploadFile|filePath=$filePath|fileName=$fileName|props=$props") val uploadFileName = fileName ?: file.name diff --git a/src/backend/ci/core/common/common-service/src/main/kotlin/com/tencent/devops/common/service/utils/CommonUtils.kt b/src/backend/ci/core/common/common-service/src/main/kotlin/com/tencent/devops/common/service/utils/CommonUtils.kt index 41c3dea9388..c9a3f4795be 100755 --- a/src/backend/ci/core/common/common-service/src/main/kotlin/com/tencent/devops/common/service/utils/CommonUtils.kt +++ b/src/backend/ci/core/common/common-service/src/main/kotlin/com/tencent/devops/common/service/utils/CommonUtils.kt @@ -126,10 +126,11 @@ object CommonUtils { userId: String, serviceUrlPrefix: String, file: File, - fileChannelType: String + fileChannelType: String, + logo: Boolean = false ): Result { - val serviceUrl = - "$serviceUrlPrefix/service/artifactories/file/upload?userId=$userId&fileChannelType=$fileChannelType" + val serviceUrl = "$serviceUrlPrefix/service/artifactories/file/upload" + + "?userId=$userId&fileChannelType=$fileChannelType&logo=$logo" logger.info("the serviceUrl is:$serviceUrl") OkhttpUtils.uploadFile(serviceUrl, file).use { response -> val responseContent = response.body()!!.string() diff --git a/src/backend/ci/core/store/biz-store-sample/src/main/kotlin/com/tencent/devops/store/service/common/impl/SampleStoreLogoServiceImpl.kt b/src/backend/ci/core/store/biz-store-sample/src/main/kotlin/com/tencent/devops/store/service/common/impl/SampleStoreLogoServiceImpl.kt index 70efd673956..bf97ed4deaa 100644 --- a/src/backend/ci/core/store/biz-store-sample/src/main/kotlin/com/tencent/devops/store/service/common/impl/SampleStoreLogoServiceImpl.kt +++ b/src/backend/ci/core/store/biz-store-sample/src/main/kotlin/com/tencent/devops/store/service/common/impl/SampleStoreLogoServiceImpl.kt @@ -44,7 +44,8 @@ class SampleStoreLogoServiceImpl : StoreLogoServiceImpl() { userId = userId, serviceUrlPrefix = serviceUrlPrefix, file = file, - fileChannelType = FileChannelTypeEnum.WEB_SHOW.name + fileChannelType = FileChannelTypeEnum.WEB_SHOW.name, + logo = true ).data // 开源版如果logoUrl的域名和ci域名一样,则logoUrl无需带上域名,防止域名变更影响图片显示(logoUrl会存db) return Result(if (logoUrl != null) StoreUtils.removeUrlHost(logoUrl) else logoUrl) diff --git a/support-files/sql/5001_ci_store-init_dml_mysql.sql b/support-files/sql/5001_ci_store-init_dml_mysql.sql index 1a709e2f3d2..70b4da29184 100755 --- a/support-files/sql/5001_ci_store-init_dml_mysql.sql +++ b/support-files/sql/5001_ci_store-init_dml_mysql.sql @@ -144,3 +144,5 @@ INSERT IGNORE INTO `T_STORE_STATISTICS_TOTAL` (`ID`, `STORE_CODE`, `STORE_TYPE`, ('0bf3fd65f97649888c1d8b7072c89299','codeP4WebHookTrigger','0','0','0','0','0.00','2021-02-24 11:23:23','2021-06-17 21:21:30','0','0'); INSERT IGNORE INTO `T_ATOM_ENV_INFO` (`ID`, `ATOM_ID`, `PKG_PATH`, `LANGUAGE`, `MIN_VERSION`, `TARGET`, `PRE_CMD`, `CREATOR`, `MODIFIER`, `CREATE_TIME`, `UPDATE_TIME`, `SHA_CONTENT`, `PKG_NAME`, `POST_ENTRY_PARAM`, `POST_CONDITION`) VALUES ('48101620b2394b728be3cfcfaa46a746','39580f08e9574fc291cdd8c51f39ddee','','java','1.8','',NULL,'system','system','2021-11-16 15:56:53','2021-11-16 15:56:53',NULL,'',NULL,NULL); + +REPLACE INTO `T_LOGO`(`ID`, `TYPE`, `LOGO_URL`, `LINK`, `CREATOR`, `MODIFIER`, `CREATE_TIME`, `UPDATE_TIME`, `ORDER`) VALUES ('ef3e60ba6ef44b92b0fec0b940af8fa1', 'BANNER', '/ms/artifactory/api/user/artifactories/file/download?filePath=%2Ffile%2Fpng%2FBANNER.png&logo=true', '', 'system', 'system', '2019-10-21 17:23:40', '2022-03-10 17:23:40', 2);