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-603 merge: Csp migration branch to release-5.2.0 #885

Merged
merged 4 commits into from
Nov 14, 2022
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 @@ -18,37 +18,20 @@ class StorageService {
@throws[Exception]
def getService: BaseStorageService = {
if (null == storageService) {
if (StringUtils.equalsIgnoreCase(storageType, "azure")) {
val storageKey = Platform.config.getString("azure_storage_key")
val storageSecret = Platform.config.getString("azure_storage_secret")
storageService = StorageServiceFactory.getStorageService(StorageConfig(storageType, storageKey, storageSecret))
} else if (StringUtils.equalsIgnoreCase(storageType, "aws")) {
val storageKey = Platform.config.getString("aws_storage_key")
val storageSecret = Platform.config.getString("aws_storage_secret")
storageService = StorageServiceFactory.getStorageService(StorageConfig(storageType, storageKey, storageSecret))
} else if (StringUtils.equalsIgnoreCase(storageType, "gcloud")) {
val storageKey = Platform.config.getString("gcloud_client_key")
val storageSecret = Platform.config.getString("gcloud_private_secret")
storageService = StorageServiceFactory.getStorageService(StorageConfig(storageType, storageKey, storageSecret))
}
// else if (StringUtils.equalsIgnoreCase(storageType, "cephs3")) {
// val storageKey = Platform.config.getString("cephs3_storage_key")
// val storageSecret = Platform.config.getString("cephs3_storage_secret")
// val endpoint = Platform.config.getString("cephs3_storage_endpoint")
// storageService = StorageServiceFactory.getStorageService(new StorageConfig(storageType, storageKey, storageSecret, Option(endpoint)))
// }
else throw new ServerException("ERR_INVALID_CLOUD_STORAGE", "Error while initialising cloud storage")
val storageKey = Platform.config.getString("cloud_storage_key")
val storageSecret = Platform.config.getString("cloud_storage_secret")
// TODO: endPoint defined to support "cephs3". Make code changes after cloud-store-sdk 2.11 support it.
val endPoint = if (Platform.config.hasPath("cloud_storage_endpoint")) Option(Platform.config.getString("cloud_storage_endpoint")) else None
storageService = StorageServiceFactory.getStorageService(new StorageConfig(storageType, storageKey, storageSecret))
}
storageService
}

def getContainerName: String = {
storageType match {
case "azure" => Platform.config.getString("azure_storage_container")
case "aws" => Platform.config.getString("aws_storage_container")
case "gcloud" => Platform.config.getString("gcloud_storage_bucket")
case _ => throw new ServerException("ERR_INVALID_CLOUD_STORAGE", "Container name not configured.")
}
if(Platform.config.hasPath("cloud_storage_container"))
Platform.config.getString("cloud_storage_container")
else
throw new ServerException("ERR_INVALID_CLOUD_STORAGE", "Cloud Storage Container name not configured.")
}

def uploadFile(folderName: String, file: File, slug: Option[Boolean] = Option(true)): Array[String] = {
Expand Down Expand Up @@ -85,10 +68,7 @@ class StorageService {
}

def getSignedURL(key: String, ttl: Option[Int], permission: Option[String]): String = {
storageType match {
case "gcloud" => getService.getPutSignedURL(getContainerName, key, ttl, permission, Option.apply(getMimeType(key)))
case _ => getService.getSignedURL (getContainerName, key, ttl, permission)
}
getService.getPutSignedURL(getContainerName, key, ttl, permission, Option.apply(getMimeType(key)))
}

def getUri(key: String): String = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,9 +473,9 @@ content.h5p.library.path="https://s3.ap-south-1.amazonaws.com/ekstep-public-dev/
# This is added to handle large artifacts sizes differently
content.artifact.size.for_online=209715200
cloud_storage_type="azure"
azure_storage_key="asdfgh"
azure_storage_secret="jhgfdcvb"
azure_storage_container="sunbird-content-dev"
cloud_storage_key="asdfgh"
cloud_storage_secret="jhgfdcvb"
cloud_storage_container="sunbird-content-dev"


validation.strictMimeType = ["image/svg+xml"]
Expand Down