Unverified Commit 659c9a4f authored by Anil Gupta's avatar Anil Gupta Committed by GitHub
Browse files

Issue #KN-603 merge: Merge pull request #885 from project-sunbird/csp-migration

Issue #KN-603 merge: Csp migration branch to release-5.2.0
Showing with 13 additions and 33 deletions
+13 -33
......@@ -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] = {
......@@ -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 = {
......
......@@ -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"]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment