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

Issue KN-000 fix: OCI cloud URL issue fix #1011

Merged
merged 2 commits into from
Nov 14, 2023
Merged
Changes from 1 commit
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 @@ -34,29 +34,18 @@ class StorageService {
throw new ServerException("ERR_INVALID_CLOUD_STORAGE", "Cloud Storage Container name not configured.")
}

def formatUrl(url: String): String = {
if (storageType == "oci") {
val newHostname: String = if (Platform.config.hasPath("cloud_storage_proxy_host")) Platform.config.getString("cloud_storage_proxy_host") else ""
val regex = "(?<=://)([^/]+)".r
val replacedUrl = regex.replaceAllIn(url, newHostname)
replacedUrl
} else {
url
}
}

def uploadFile(folderName: String, file: File, slug: Option[Boolean] = Option(true)): Array[String] = {
val slugFile = if (slug.getOrElse(true)) Slug.createSlugFile(file) else file
val objectKey = folderName + "/" + slugFile.getName
val url = getService.upload(getContainerName, slugFile.getAbsolutePath, objectKey, Option.apply(false), Option.apply(1), Option.apply(5), Option.empty)
Array[String](objectKey, formatUrl(url))
Array[String](objectKey, url)
}

def uploadDirectory(folderName: String, directory: File, slug: Option[Boolean] = Option(true)): Array[String] = {
val slugFile = if (slug.getOrElse(true)) Slug.createSlugFile(directory) else directory
val objectKey = folderName + File.separator
val url = getService.upload(getContainerName, slugFile.getAbsolutePath, objectKey, Option.apply(true), Option.apply(1), Option.apply(5), Option.empty)
Array[String](objectKey, formatUrl(url))
Array[String](objectKey, url)
}

def uploadDirectoryAsync(folderName: String, directory: File, slug: Option[Boolean] = Option(true))(implicit ec: ExecutionContext): Future[List[String]] = {
Expand Down
Loading