Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Creating and uploading file to AEM instance via CRX using wcm.io tools
package org.aem.sync.kotlin
import io.wcm.tooling.commons.contentpackagebuilder.ContentPackageBuilder
import io.wcm.tooling.commons.packmgr.PackageManagerProperties
import io.wcm.tooling.commons.packmgr.install.PackageFile
import io.wcm.tooling.commons.packmgr.install.PackageInstaller
import io.wcm.tooling.commons.packmgr.install.VendorInstallerFactory
import java.io.File
fun main(args: Array<String>) {
val file = File("mypackage.zip")
val builder = ContentPackageBuilder()
.name("name")
.group("group")
.rootPath("/apps/mysample/config")
builder.build(file).use { contentPackage ->
val myFile = File(ClassLoader.getSystemClassLoader().getResource("file.txt").file)
contentPackage.addFile("/apps/mysample/config/file1.txt", myFile)
}
val props = PackageManagerProperties()
props.userId = "admin"
props.password = "admin"
props.packageManagerUrl = "http://localhost:4502" + VendorInstallerFactory.CRX_URL
val packageFile = PackageFile()
packageFile.file = file
packageFile.setForce(true)
val logger = MyLogger()
val packageInstaller = PackageInstaller(props, logger)
packageInstaller.installFile(packageFile)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.