aem-plugin / com.cognifide.gradle.aem.common.file.transfer / FileTransferManager

FileTransferManager

class FileTransferManager : FileTransfer

Facade for transferring files over multiple protocols HTTP/SFTP/SMB and custom.

Handles locking files for avoiding uncompleted downloads. Prevents unnecessary download if file on local server already exist. Prevents unnecessary uploads if file on remote servers already exist.

Constructors

<init>

Facade for transferring files over multiple protocols HTTP/SFTP/SMB and custom.

FileTransferManager(aem: AemExtension)

Properties

credentials

val credentials: Pair<String, String>

credentialsString

val credentialsString: String

domain

var domain: String?

factory

val factory: FileTransferFactory

http

val http: HttpFileTransfer

password

var password: String?

path

val path: PathFileTransfer

resolve

val resolve: ResolveFileTransfer

sftp

val sftp: SftpFileTransfer

smb

val smb: SmbFileTransfer

url

val url: UrlFileTransfer

user

var user: String?

Functions

credentials

Shorthand method to set same credentials for all protocols requiring it.

fun credentials(user: String?, password: String?, domain: String? = null): Unit

custom

Register custom file transfer for e.g downloading / uploading files from cloud storages like: Amazon S3, Google Cloud Storage etc.

fun custom(name: String, definition: CustomFileTransfer.() -> Unit): Unit

deleteFrom

Deletes file of given name in directory at specified URL.

fun deleteFrom(dirUrl: String, fileName: String): Unit

download

Downloads file from specified URL to temporary directory with preserving file name.

fun download(fileUrl: String): Unit

downloadFrom

Downloads file of given name from directory at specified URL.

fun downloadFrom(dirUrl: String, fileName: String, target: File): Unit

downloadUsing

Downloads file from specified URL using dedicated transfer type.

fun downloadUsing(transfer: FileTransfer, fileUrl: String, target: File): Unit

Downloads file of given name from directory at specified URL using dedicated transfer type.

fun downloadUsing(transfer: FileTransfer, dirUrl: String, fileName: String, target: File): Unit

handles

Check if there is any file transfer supporting specified URL.

fun handles(fileUrl: String): Boolean

handling

Get file transfer supporting specified URL.

fun handling(fileUrl: String): FileTransferHandler

http

fun http(options: HttpFileTransfer.() -> Unit): Unit

list

Lists files in directory available at specified URL.

fun list(dirUrl: String): List<FileEntry>

named

Get custom (or built-in) file transfer by name.

fun named(name: String): FileTransfer

path

fun path(options: PathFileTransfer.() -> Unit): Unit

resolve

fun resolve(options: ResolveFileTransfer.() -> Unit): Unit

sftp

fun sftp(options: SftpFileTransfer.() -> Unit): Unit

smb

fun smb(options: SmbFileTransfer.() -> Unit): Unit

stat

Gets file status of given name in directory at specified URL.

fun stat(dirUrl: String, fileName: String): FileEntry?

truncate

Deletes all files in directory available at specified URL.

fun truncate(dirUrl: String): Unit

uploadTo

Uploads file to directory at specified URL and set given name.

fun uploadTo(dirUrl: String, fileName: String, source: File): Unit

uploadUsing

Uploads file to file at specified URL using dedicated transfer type.

fun uploadUsing(transfer: FileTransfer, fileUrl: String, source: File): Unit

Uploads file to directory at specified URL and set given name using dedicated transfer type.

fun uploadUsing(transfer: FileTransfer, dirUrl: String, fileName: String, source: File): Unit

url

fun url(options: UrlFileTransfer.() -> Unit): Unit

Companion Object Properties

NAME

const val NAME: String

TMP_SUFFIX

const val TMP_SUFFIX: String