override fun getSignedUrl()

in google-storage-server/src/main/kotlin/jetbrains/buildServer/serverSide/artifacts/google/signedUrl/GoogleSignedUrlProviderImpl.kt [30:70]


    override fun getSignedUrl(
        httpMethod: HttpMethod,
        path: String,
        parameters: Map<String, String>
    ): Pair<String, Int> {
        val lifeTime = urlLifetimeSec
        val resolver = { IOGuard.allowNetworkCall(FuncThrow {
            val bucket = GoogleUtils.getStorageBucket(parameters)
            val blobInfo = BlobInfo.newBuilder(bucket, path)
            val urlOptions = arrayListOf<Storage.SignUrlOption>(
                Storage.SignUrlOption.httpMethod(httpMethod),
                Storage.SignUrlOption.withV4Signature()
            )

            if (httpMethod.name() == "POST") {
                urlOptions.add(
                    Storage.SignUrlOption.withExtHeaders(
                        mapOf(
                            "x-goog-resumable" to "start",
                            "Content-Type" to parameters["contentType"]
                        )
                    )
                )
                urlOptions.add(Storage.SignUrlOption.withContentType())
                blobInfo.setContentType(parameters["contentType"])
            }

            bucket.storage.signUrl(blobInfo.build(), lifeTime.toLong(), TimeUnit.SECONDS, *urlOptions.toTypedArray())
                .toString()
                .also {
                    LOG.debug("signedURL: $it")
                    LOG.debug("contentType: ${parameters["contentType"]}")
                }
        })}

        if (httpMethod == HttpMethod.GET && TeamCityProperties.getBoolean(GoogleConstants.SIGNED_URL_GET_CACHE_ENABLED)) {
            return myLinksCache.get(getIdentity(parameters, path), resolver) to lifeTime
        }

        return resolver() to lifeTime
    }