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

4.8.3 upload fix #63

Merged
merged 7 commits into from
Sep 5, 2023
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 @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down