-
- All Implemented Interfaces:
-
com.cognifide.gradle.common.file.transfer.FileTransfer
public final class FileTransferManager implements 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.
-
-
Field Summary
Fields Modifier and Type Field Description private final Property<String>userprivate final Property<String>passwordprivate final Property<String>domainprivate final Pair<String, String>credentialsprivate final StringcredentialsStringprivate final FileTransferFactoryfactoryprivate final HttpFileTransferhttpprivate final SftpFileTransfersftpprivate final SmbFileTransfersmbprivate final ResolveFileTransferresolveprivate final UrlFileTransferurlprivate final PathFileTransferpath
-
Constructor Summary
Constructors Constructor Description FileTransferManager(CommonExtension common)
-
Method Summary
Modifier and Type Method Description final Unitcredentials(String user, String password, String domain)Shorthand method to enforce credentials for all protocols requiring it. final Unithttp(Function1<HttpFileTransfer, Unit> options)final Unitsftp(Function1<SftpFileTransfer, Unit> options)final Unitsmb(Function1<SmbFileTransfer, Unit> options)final Unitresolve(Function1<ResolveFileTransfer, Unit> options)final Uniturl(Function1<UrlFileTransfer, Unit> options)final Unitpath(Function1<PathFileTransfer, Unit> options)Filedownload(String fileUrl)Downloads file from specified URL to temporary directory with preserving file name. UnitdownloadFrom(String dirUrl, String fileName, File target)Downloads file of given name from directory at specified URL. final UnitdownloadUsing(FileTransfer transfer, String fileUrl, File target)Downloads file from specified URL using dedicated transfer type. final UnitdownloadUsing(FileTransfer transfer, String dirUrl, String fileName, File target)Downloads file of given name from directory at specified URL using dedicated transfer type. UnituploadTo(String dirUrl, String fileName, File source)Uploads file to directory at specified URL and set given name. final UnituploadUsing(FileTransfer transfer, String fileUrl, File source)Uploads file to file at specified URL using dedicated transfer type. final UnituploadUsing(FileTransfer transfer, String dirUrl, String fileName, File source)Uploads file to directory at specified URL and set given name using dedicated transfer type. List<FileEntry>list(String dirUrl)Lists files in directory available at specified URL. UnitdeleteFrom(String dirUrl, String fileName)Deletes file of given name in directory at specified URL. Unittruncate(String dirUrl)Deletes all files in directory available at specified URL. FileEntrystat(String dirUrl, String fileName)Gets file status of given name in directory at specified URL. Booleanhandles(String fileUrl)Check if there is any file transfer supporting specified URL. final FileTransferHandlerhandling(String fileUrl)Get file transfer supporting specified URL. final Unitcustom(String name, Function1<CustomFileTransfer, Unit> definition)Register custom file transfer for e.g downloading / uploading files from cloud storages like: Amazon S3, Google Cloud Storage etc. final FileTransfernamed(String name)Get custom (or built-in) file transfer by name. final Property<String>getUser()final Property<String>getPassword()final Property<String>getDomain()final Pair<String, String>getCredentials()final StringgetCredentialsString()final FileTransferFactorygetFactory()final HttpFileTransfergetHttp()final SftpFileTransfergetSftp()final SmbFileTransfergetSmb()final ResolveFileTransfergetResolve()final UrlFileTransfergetUrl()final PathFileTransfergetPath()-
Methods inherited from class com.cognifide.gradle.common.file.transfer.FileTransferManager
delete, download, downloadTo, exists, exists, stat, upload, uploadTo -
Methods inherited from class com.cognifide.gradle.common.file.transfer.FileTransfer
equals, hashCode, toString -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
FileTransferManager
FileTransferManager(CommonExtension common)
-
-
Method Detail
-
credentials
final Unit credentials(String user, String password, String domain)
Shorthand method to enforce credentials for all protocols requiring it.
-
http
final Unit http(Function1<HttpFileTransfer, Unit> options)
-
sftp
final Unit sftp(Function1<SftpFileTransfer, Unit> options)
-
smb
final Unit smb(Function1<SmbFileTransfer, Unit> options)
-
resolve
final Unit resolve(Function1<ResolveFileTransfer, Unit> options)
-
url
final Unit url(Function1<UrlFileTransfer, Unit> options)
-
path
final Unit path(Function1<PathFileTransfer, Unit> options)
-
download
File download(String fileUrl)
Downloads file from specified URL to temporary directory with preserving file name.
-
downloadFrom
Unit downloadFrom(String dirUrl, String fileName, File target)
Downloads file of given name from directory at specified URL.
-
downloadUsing
final Unit downloadUsing(FileTransfer transfer, String fileUrl, File target)
Downloads file from specified URL using dedicated transfer type.
-
downloadUsing
final Unit downloadUsing(FileTransfer transfer, String dirUrl, String fileName, File target)
Downloads file of given name from directory at specified URL using dedicated transfer type.
-
uploadTo
Unit uploadTo(String dirUrl, String fileName, File source)
Uploads file to directory at specified URL and set given name.
-
uploadUsing
final Unit uploadUsing(FileTransfer transfer, String fileUrl, File source)
Uploads file to file at specified URL using dedicated transfer type.
-
uploadUsing
final Unit uploadUsing(FileTransfer transfer, String dirUrl, String fileName, File source)
Uploads file to directory at specified URL and set given name using dedicated transfer type.
-
deleteFrom
Unit deleteFrom(String dirUrl, String fileName)
Deletes file of given name in directory at specified URL.
-
stat
FileEntry stat(String dirUrl, String fileName)
Gets file status of given name in directory at specified URL.
-
handles
Boolean handles(String fileUrl)
Check if there is any file transfer supporting specified URL.
-
handling
final FileTransferHandler handling(String fileUrl)
Get file transfer supporting specified URL.
-
custom
final Unit custom(String name, Function1<CustomFileTransfer, Unit> definition)
Register custom file transfer for e.g downloading / uploading files from cloud storages like: Amazon S3, Google Cloud Storage etc.
-
named
final FileTransfer named(String name)
Get custom (or built-in) file transfer by name.
-
getPassword
final Property<String> getPassword()
-
getCredentials
final Pair<String, String> getCredentials()
-
getCredentialsString
final String getCredentialsString()
-
getFactory
final FileTransferFactory getFactory()
-
getHttp
final HttpFileTransfer getHttp()
-
getSftp
final SftpFileTransfer getSftp()
-
getSmb
final SmbFileTransfer getSmb()
-
getResolve
final ResolveFileTransfer getResolve()
-
getUrl
final UrlFileTransfer getUrl()
-
getPath
final PathFileTransfer getPath()
-
-
-
-