diff --git a/platform-modules/mimetype-manager/src/main/scala/org/sunbird/mimetype/mgr/BaseMimeTypeManager.scala b/platform-modules/mimetype-manager/src/main/scala/org/sunbird/mimetype/mgr/BaseMimeTypeManager.scala index c357443c5..416d75925 100644 --- a/platform-modules/mimetype-manager/src/main/scala/org/sunbird/mimetype/mgr/BaseMimeTypeManager.scala +++ b/platform-modules/mimetype-manager/src/main/scala/org/sunbird/mimetype/mgr/BaseMimeTypeManager.scala @@ -214,6 +214,20 @@ class BaseMimeTypeManager(implicit ss: StorageService) { } } + def extractPackageInCloudAsync(objectId: String, uploadFile: File, node: Node, extractionType: String, slugFile: Boolean)(implicit ec: ExecutionContext): Future[List[String]] = { + val file = Slug.createSlugFile(uploadFile) + val mimeType = node.getMetadata.get("mimeType").asInstanceOf[String] + validationForCloudExtraction(file, extractionType, mimeType) + if(extractableMimeTypes.contains(mimeType)){ + val extractionBasePath = getBasePath(objectId) + extractPackage(file, extractionBasePath) + ss.uploadDirectoryAsync(getExtractionPath(objectId, node, extractionType, mimeType), new File(extractionBasePath), Option(slugFile)) + } else { + val emptyFuture: Future[List[String]] = Future.successful(List.empty[String]) + emptyFuture + } + } + def extractH5PPackageInCloud(objectId: String, extractionBasePath: String, node: Node, extractionType: String, slugFile: Boolean)(implicit ec: ExecutionContext): Future[List[String]] = { val mimeType = node.getMetadata.get("mimeType").asInstanceOf[String] if(null == extractionType) diff --git a/platform-modules/mimetype-manager/src/main/scala/org/sunbird/mimetype/mgr/impl/HtmlMimeTypeMgrImpl.scala b/platform-modules/mimetype-manager/src/main/scala/org/sunbird/mimetype/mgr/impl/HtmlMimeTypeMgrImpl.scala index 8418d2180..1ba192dec 100644 --- a/platform-modules/mimetype-manager/src/main/scala/org/sunbird/mimetype/mgr/impl/HtmlMimeTypeMgrImpl.scala +++ b/platform-modules/mimetype-manager/src/main/scala/org/sunbird/mimetype/mgr/impl/HtmlMimeTypeMgrImpl.scala @@ -18,13 +18,13 @@ class HtmlMimeTypeMgrImpl(implicit ss: StorageService) extends BaseMimeTypeManag override def upload(objectId: String, node: Node, uploadFile: File, filePath: Option[String], params: UploadParams)(implicit ec: ExecutionContext): Future[Map[String, AnyRef]] = { validateUploadRequest(objectId, node, uploadFile) val indexHtmlValidation: Boolean = if (Platform.config.hasPath("indexHtmlValidation.env")) Platform.config.getBoolean("indexHtmlValidation.env") else true - TelemetryManager.error("Value of indexHtmlValidation: " + indexHtmlValidation) + TelemetryManager.log("Value of indexHtmlValidation: " + indexHtmlValidation) val flag: Boolean = if (indexHtmlValidation) isValidPackageStructure(uploadFile, List[String]("index.html")) else true if (flag) { val urls = uploadArtifactToCloud(uploadFile, objectId, filePath) node.getMetadata.put("s3Key", urls(IDX_S3_KEY)) node.getMetadata.put("artifactUrl", urls(IDX_S3_URL)) - extractPackageInCloud(objectId, uploadFile, node, "snapshot", false) + Future { extractPackageInCloudAsync(objectId, uploadFile, node, "snapshot", false) } Future(Map[String, AnyRef]("identifier" -> objectId, "artifactUrl" -> urls(IDX_S3_URL), "s3Key" -> urls(IDX_S3_KEY), "size" -> getFileSize(uploadFile).asInstanceOf[AnyRef])) } else { TelemetryManager.error("ERR_INVALID_FILE" + "Please Provide Valid File! with file name: " + uploadFile.getName)