override fun processDownload()

in google-storage-server/src/main/kotlin/jetbrains/buildServer/serverSide/artifacts/google/web/GoogleArtifactDownloadProcessor.kt [21:52]


    override fun processDownload(artifactInfo: StoredBuildArtifactInfo,
                                 buildPromotion: BuildPromotion,
                                 request: HttpServletRequest,
                                 response: HttpServletResponse): Boolean {
        val artifactData = artifactInfo.artifactData
                ?: throw IOException("Can not process artifact download request for a folder")

        val path = GoogleUtils.getArtifactPath(artifactInfo.commonProperties, artifactData.path)
        val parameters = artifactInfo.storageSettings

        val result = try {
            signedUrlProvider.getSignedUrl(HttpMethod.GET, path, parameters)
        } catch (e: StorageException) {
            val errorType = if (e.isRetryable) "intermittent" else ""
            val message = "Failed to get signed URL for blob $path due to $errorType Google Cloud Storage error, try to access it later"
            LOG.infoAndDebugDetails(message, e)

            response.status = HttpServletResponse.SC_BAD_GATEWAY
            response.sendError(HttpServletResponse.SC_BAD_GATEWAY, e.message)

            return true
        } catch (e: Throwable) {
            val message = "Failed to get signed URL for blob $path from Google Cloud Storage due to unexpected error"
            LOG.warnAndDebugDetails(message, e)
            throw IOException(message + ": " + e.message, e)
        }

        response.setHeader(HttpHeaders.CACHE_CONTROL, "max-age=" + result.second)
        response.sendRedirect(result.first)

        return true
    }