Class VfsMethods
- java.lang.Object
-
- io.toro.martini.VfsMethods
-
public final class VfsMethods extends Object
This class provides one-liner methods for sending/receiving files to/from a remote server.
Connects to an external URL to retrieve/send the content of files.
-
-
Constructor Summary
Constructors Constructor Description VfsMethods(io.toro.martini.email.EmailClient esbEmailClient, io.toro.martini.vfs.VfsClient esbVfsClient)
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
close(org.apache.commons.vfs2.FileObject fileObject)
Closes aFileObject
.static String
copyTo(String sourceUrl, String targetUrl)
Copy the item found in the source url to the target url.static void
createFile(org.apache.commons.vfs2.FileObject fileObject)
Creates the provided file, if it does not exist.static void
createFolder(org.apache.commons.vfs2.FileObject fileObject)
Creates the provided folder, if it does not exist.static boolean
delete(org.apache.commons.vfs2.FileObject fileObject)
Deletes a file.static void
deleteAll(org.apache.commons.vfs2.FileObject fileObject)
Deletes a file and its children, if any.static boolean
exists(org.apache.commons.vfs2.FileObject fileObject)
Determines if the provided file exists.static org.apache.commons.vfs2.FileObject
file(String url)
Gets theFileObject
of a file that's on a virtual file system.static org.apache.commons.vfs2.FileObject
file(String url, Map properties)
Gets theFileObject
of a file that's on a virtual file system.static Object
getAttribute(org.apache.commons.vfs2.FileContent fileContent, String attrName)
Get the attribute value of a named file attribute.static String[]
getAttributeNames(org.apache.commons.vfs2.FileContent fileContent)
Get the attribute names of a file.static GloopModel
getChild(org.apache.commons.vfs2.FileObject fileObject, String name)
Returns the childFileObject
of the providedFileObject
.static GloopModel
getChildren(org.apache.commons.vfs2.FileObject fileObject)
Gets the children of aFileObject
.static GloopModel
getContent(org.apache.commons.vfs2.FileObject fileObject)
Get the content of the providedFileObject
.static GloopModel
getFile(org.apache.commons.vfs2.FileContent fileObject)
Get theFileObject
to which the providedFileContent
belongs tostatic InputStream
getInputStream(org.apache.commons.vfs2.FileContent fileContent)
Get an input stream for reading the provided file content.static long
getLastModifiedTime(org.apache.commons.vfs2.FileContent fileContent)
Get the time the file content was last modified.static GloopModel
getName(org.apache.commons.vfs2.FileObject fileObject)
Get the name of the providedFileObject
.static OutputStream
getOutputStream(org.apache.commons.vfs2.FileContent fileContent)
Gets the output stream of the file content object if it's a file.static GloopModel
getParent(org.apache.commons.vfs2.FileObject fileObject)
Get the parent of aFileObject
.static long
getSize(org.apache.commons.vfs2.FileContent fileContent)
Get the size of the provided file content.static GloopModel
getVfsFile(String url, GloopModel vfsFileSystemOptions, GloopExecutionContext context)
Gets theFileObject
of a file that's on a virtual file system.static boolean
hasAttribute(org.apache.commons.vfs2.FileContent fileContent, String attributeName)
Determines whether or not a file has a specific attribute.static boolean
isOpen(org.apache.commons.vfs2.FileContent fileContent)
Checks whether or not a file is open.static void
readFile(org.apache.commons.vfs2.FileContent fileContent, OutputStream outputStream, int bufferSize)
Reads the content from thefileContent
, writing it tooutputStream
.static void
readFile(org.apache.commons.vfs2.FileContent fileContent, org.apache.commons.vfs2.FileContent targetContent)
Reads the content from thefileContent
, writing it totargetContent
.static void
readFile(org.apache.commons.vfs2.FileContent fileContent, org.apache.commons.vfs2.FileObject targetObject)
Reads the content from thefileContent
, writing it totargetObject
.static byte[]
readFileAsBytes(org.apache.commons.vfs2.FileContent fileContent, int bufferSize)
Reads the content of the file, returning it as an array of bytes.static String
readFileAsString(org.apache.commons.vfs2.FileContent fileContent, int bufferSize)
Reads the content of the file, returning it as a string.static javax.mail.Message[]
receive(String url)
Retrieve an array of unread email messages.static javax.mail.Message[]
receive(String url, boolean delete)
Retrieve an array of unused email messages.static void
refresh(org.apache.commons.vfs2.FileObject fileObject)
Synchronize the file with the underlying file system.static void
removeAttribute(org.apache.commons.vfs2.FileContent fileContent, String attributeName)
Removes an attribute from a filestatic GloopModel
resolveFile(org.apache.commons.vfs2.FileObject fileObject, String path)
Resolve a file relative to the providedFileObject
.static byte[]
send(String url, byte[] data)
Sends bytes of data to a remote location.static byte[]
send(String url, byte[] data, Map properties)
Sends bytes of data to a remote location.static File
send(String url, File file)
Sends a file to a remote location.static void
send(String url, InputStream is)
Sends stream to a remote location.static void
send(String url, Reader reader)
Sends the contents of a reader to a remote location.static String
send(String url, String data)
Sends string to a remote location.static File
send(String url, Map properties, File file)
Sends a file to a remote location.static void
send(String url, Map properties, InputStream is)
Sends a stream to a remote location.static void
send(String url, Map properties, Reader reader)
Sends the contents of a reader to a remote location.static void
send(String url, Map properties, Reader data, List<javax.activation.DataSource> attachment)
Sends bytes of data to a remote location.static String
send(String url, Map properties, String data)
Sends string to a remote location.static String
send(String url, Map properties, String data, List<javax.activation.DataSource> attachment)
Sends string to a remote location.static byte[]
sendTo(byte[] data, String url)
Sends bytes of data to a remote location.static File
sendTo(File file, String url)
Sends a file to a remote location.static File
sendTo(File file, String url, Map properties)
Sends a file to a remote location.static void
sendTo(InputStream is, String url)
Sends stream to a remote location.static void
sendTo(InputStream is, String url, Map properties)
Sends a stream to a remote location.static void
sendTo(Reader reader, String url)
Sends the contents of a reader to a remote location.static void
sendTo(Reader reader, String url, Map properties)
Sends the contents of a reader to a remote location.static String
sendTo(String data, String url)
Sends string to a remote location.static String
sendTo(String data, String url, Map properties)
Sends string to a remote location.static byte[]
sendTo(String url, Map properties, byte[] data)
Sends bytes of data to a remote location.static void
setAttribute(org.apache.commons.vfs2.FileContent fileContent, String attributeName, Object value)
Sets a file attribute's valuestatic void
setExecutable(org.apache.commons.vfs2.FileObject fileObject, boolean executable, boolean ownerOnly)
Sets the executable flag of theFileObject
.static void
setLastModifiedTime(org.apache.commons.vfs2.FileContent fileContent, long lastModifiedTime)
Sets the last modified time of the given file if it it exists.static void
setReadable(org.apache.commons.vfs2.FileObject fileObject, boolean readable, boolean ownerOnly)
Sets the readable flag of theFileObject
.static void
setWritable(org.apache.commons.vfs2.FileObject fileObject, boolean writable, boolean ownerOnly)
Sets the writeable flag of theFileObject
.static String
vfsGet(String url)
Gets the string content of a file that's on a virtual file system.static String
vfsGet(String url, Map properties)
Gets the string content of a file that's on a virtual file system.static byte[]
vfsGetBytes(String url)
Gets the byte array content of a file that's on a virtual file system.static byte[]
vfsGetBytes(String url, Map properties)
Gets the stream of a file that's on a virtual file system.static File
vfsGetFile(String url, String filename)
Gets the content of a file that's on a virtual file system and writes it to the given file.static File
vfsGetFile(String url, String filename, Map properties)
Writes a file from a virtual file system to the local file system.static InputStream
vfsGetInputStream(String url)
Gets the stream of a file that's on a virtual file system.static void
vfsGetInputStream(String url, Closure closure)
Executes a closure upon fetching the stream of a file that's on a virtual file system.static InputStream
vfsGetInputStream(String url, Map properties)
Gets the stream of a file that's on a virtual file system.static void
vfsGetInputStream(String url, Map properties, Closure closure)
Executes a closure upon fetching the stream of a file that's on a virtual file system.static void
vfsPut(String url, byte[] data)
Alias forsend(String, byte[])
.static void
vfsPut(String url, byte[] data, Map properties)
Alias for {@link #send(String, byte[], Map}.static void
vfsPut(String url, InputStream data)
Alias for {@link #send(String, InputStream}.static void
vfsPut(String url, InputStream data, Map properties)
Alias forsend(String, Map, InputStream)
.static void
vfsPut(String url, String data)
Alias forsend(String, String)
.static void
vfsPut(String url, String data, Map properties)
Alias forsend(String, Map, String)
.static void
writeFile(org.apache.commons.vfs2.FileContent fileContent, byte[] data, boolean append, int bufferSize)
Writes an array of bytes to the file.static void
writeFile(org.apache.commons.vfs2.FileContent fileContent, InputStream inputStream, boolean append)
Writes the content of the input stream to thefileContent
, with a buffer size of4096
.static void
writeFile(org.apache.commons.vfs2.FileContent fileContent, InputStream inputStream, boolean append, int bufferSize)
Writes the content of the input stream to thefileContent
.static void
writeFile(org.apache.commons.vfs2.FileContent fileContent, String data, boolean append, int bufferSize)
Writes the content of the input string to the file.
-
-
-
Constructor Detail
-
VfsMethods
@Autowired VfsMethods(io.toro.martini.email.EmailClient esbEmailClient, io.toro.martini.vfs.VfsClient esbVfsClient)
-
-
Method Detail
-
vfsGet
public static String vfsGet(String url) throws ToroException
Gets the string content of a file that's on a virtual file system.
Supported file systems are:
- Local
- HTTP
- HTTPS
- FTP
- FTPS
- SFTP
Example usages:
println 'file://path/to/local-file.txt'.vfsGet() println 'http://www.home.com/remote-file.txt'.vfsGet() println 'https://www.secure-home.com/remote-file.txt'.vfsGet() println 'ftp://login:password@127.0.0.1/home/login/remote-file.txt'.vfsGet() println 'ftps://login:password@127.0.0.1/home/login/remote-file.txt'.vfsGet() println 'sftp://login:password@127.0.0.1/home/login/remote-file.txt'.vfsGet()
- Parameters:
url
- the URL to download the remote file from- Returns:
- The content of the remote file
- Throws:
ToroException
- if an error occurs during this operation- Since:
- 1.0
-
vfsGet
public static String vfsGet(String url, Map properties) throws ToroException
Gets the string content of a file that's on a virtual file system.
Supported file systems are:
- Local
- HTTP
- HTTPS
- FTP
- FTPS
- SFTP
- Dropbox - requires an access token; optional properties include the application name, user locale, auto-retry (that is, if a retry should ensue after a failed request), max retries (if auto-retry is enabled, the default value is 3)
- Google Drive - requires an access token; a refresh token may also be specified but the client ID
and client secret must be defined as well; other optional properties include the application name and
auto-retry.
Note:Use the OAuth 2.0 for the required
properties
- Amazon S3 - requires an access key, secret key, region and bucket name
- OneDrive - requires an access token, refresh token, client ID, client secret, and redirect uri. only the access token is used when sending authenticated request, and the rest are required for refreshing the access token when it expires
The possible entries in the
properties
map varies depending on the target virtual file system. But in general, for requests that need an access token, the following maps are accepted:['credential': ['accessToken': 'your-access-token']] ['credential': new OauthTokenAuthenticator('your-access-token')]
And if a username and password must be specified, the user can use a map like:
['credential': ['username': 'your-user-name', 'password': 'your-password', 'domain':'www.your-domain.com']]
Example usage in FTP:
println 'ftp://login:password@127.0.0.1/home/login/remote-file.txt'.vfsGet([ssl:"false", passive:"true"])
Example usage in Dropbox:
println 'dbx://path/to/foo.txt'.vfsGet([ 'applicationName': 'ApplicationName/Version', 'accessToken': 'your-access-token', 'userLocale': Locale.getDefault(), 'autoRetry': true, 'maxRetries': 5])
Example usage in Google Drive:
println 'gdv://path/to/foo.txt'.vfsGet([ 'applicationName': 'ApplicationName/Version', 'clientId': 'your-client-id', 'clientSecret': 'your-client-secret', 'refreshToken': 'your-refresh-token', 'accessToken': 'your-access-token', 'autoRetry': true])
Example usage in Amazon S3
println 's3://path/to/foo.txt'.vfsGet([ 'accesskey': 'your-access-key', 'secretkey': 'your-secret-key', 'region': 'your-region', 'bucketName': 'your-bucket-name'])
Example usage in OneDrive:
println 'od://path/to/foo.txt'.vfsGet([ 'accessToken': 'your-access-token', 'refreshToken': 'your-refresh-token', 'clientId': 'your-clientId', 'clientSecret': 'your-clientSecret', 'redirectUri': 'your-redirect-uri' ])
- Parameters:
url
- the URL to download the remote file fromproperties
- optional properties for the request- Returns:
- the content of the remote file
- Throws:
ToroException
- if an error occurs during this operation- Since:
- 1.0
- See Also:
vfsGet(String)
-
vfsGetInputStream
public static InputStream vfsGetInputStream(String url, Map properties) throws ToroException
Gets the stream of a file that's on a virtual file system.
Supported file systems are:
- Local
- HTTP
- HTTPS
- FTP
- FTPS
- SFTP
- Dropbox - requires an access token; optional properties include the application name, user locale, auto-retry (that is, if auto-retry is enabled), max retries (if auto-retry is enabled, default is 3)
- Google Drive - requires an access token; a refresh token may also be specified but the client ID
and client secret must be defined as well; other optional properties include the application name and
auto-retry
Note:Use the OAuth 2.0 for the required
properties
- Amazon S3 - requires an access token, secret key, region and bucket name
- OneDrive - requires an access token, refresh token, client ID, client secret, and redirect uri. only the access token is used when sending authenticated request, and the rest are required for refreshing the access token when it expires
The possible entries in the
properties
map varies depending on the target virtual file system. But in general, for requests that need an access token, the following maps are accepted:['credential': ['accessToken': ''accesskey': 'your-access-key'']] ['credential': new OauthTokenAuthenticator('your-access-token')]
And if a username and password must be specified, the user can use a map like:
['credential': ['username': 'your-user-name', 'password': 'your-password', 'domain':'www.your-domain.com']]
Example usage in FTP:
def inputStream = 'ftp://login:password@127.0.0.1/home/login/remote-file.txt'.vfsGetInputStream( [ssl:"false", passive:"true"])
Example usage in Dropbox:
def inputStream = 'dbx://path/to/foo.txt'.vfsGetInputStream([ 'applicationName': 'ApplicationName/Version', 'accessToken': 'your-access-token', 'userLocale': Locale.getDefault(), 'autoRetry': true, 'maxRetries': 5])
Example usage in Google Drive:
def inputStream = 'gdv://path/to/foo.txt'.vfsGetInputStream([ 'applicationName': 'ApplicationName/Version', 'clientId': 'your-client-id', 'clientSecret': 'your-client-secret', 'refreshToken': 'your-refresh-token', 'accessToken': 'your-access-token', 'autoRetry': true])
Example usage in Amazon S3:
def inputStream = 's3://path/to/foo.txt'.vfsGetInputStream([ 'accesskey': 'your-access-key', 'secretkey': 'your-secret-key', 'region': 'your-region', 'bucketName': 'your-bucket-name'])
Example usage in OneDrive:
def inputStream = 'od://path/to/foo.txt'.vfsGetInputStream([ 'accessToken': 'your-access-token', 'refreshToken': 'your-refresh-token', 'clientId': 'your-clientId', 'clientSecret': 'your-clientSecret', 'redirectUri': 'your-redirect-uri'])
- Parameters:
url
- the URL to download the remote file fromproperties
- optional properties for the request- Returns:
- the content of the remote file
- Throws:
ToroException
- if an error occurs during this operation- Since:
- 1.0
-
vfsGetInputStream
public static InputStream vfsGetInputStream(String url) throws ToroException
Gets the stream of a file that's on a virtual file system.
Supported file systems are:
- Local
- HTTP
- HTTPS
- FTP
- FTPS
- SFTP
Example usages:
inputStream = 'file://path/to/local-file.txt'.vfsGetInputStream() inputStream = 'http://www.home.com/remote-file.txt'.vfsGetInputStream() inputStream = 'https://www.secure-home.com/remote-file.txt'.vfsGetInputStream() inputStream = 'ftp://login:password@127.0.0.1/home/login/remote-file.txt'.vfsGetInputStream() inputStream = 'ftps://login:password@127.0.0.1/home/login/remote-file.txt'.vfsGetInputStream() inputStream = 'sftp://login:password@127.0.0.1/home/login/remote-file.txt'.vfsGetInputStream()
- Parameters:
url
- the URL to download the remote file from- Returns:
- the content of the remote file
- Throws:
ToroException
- if an error occurs during this operation- Since:
- 1.0
- See Also:
vfsGetInputStream(String, Closure)
,vfsGetInputStream(String, Map)
,vfsGetInputStream(String, Map, Closure)
-
vfsGetInputStream
public static void vfsGetInputStream(String url, Map properties, Closure closure) throws ToroException
Executes a closure upon fetching the stream of a file that's on a virtual file system.
The stream will be closed once the closure has finished executing. Supported file systems are:
- Local
- HTTP
- HTTPS
- FTP
- FTPS
- SFTP
- Dropbox - requires an access token; optional properties include the application name, user locale, auto-retry (that is, if auto-retry is enabled), max retries (if auto-retry is enabled, default is 3)
- Google Drive - requires an access token; a refresh token may also be specified but the client ID
and client secret must be defined as well; other optional properties include the application name and
auto-retry
Note:Use the OAuth 2.0 for the required
properties
- Amazon S3 - requires an access token, secret key, region and bucket name
- OneDrive - requires an access token, refresh token, client ID, client secret, and redirect uri. only the access token is used when sending authenticated request, and the rest are required for refreshing the access token when it expires
The possible entries in the
properties
map varies depending on the target virtual file system. But in general, for requests that need an access token, the following maps are accepted:['credential': ['accessToken': 'your-access-token']] ['credential': new OauthTokenAuthenticator('your-access-token')]
And if a username and password must be specified, the user can use a map like:
['credential': ['username': 'your-user-name', 'password': 'your-password', 'domain':'www.your-domain.com']]
Example usage in FTP:
'ftp://login:password@127.0.0.1/home/login/remote-file.txt'.vfsGetInputStream( [ssl:"false", passive:"true"], inputStream -> Files.copy(${inputStream}, Paths.get('path', 'to', 'target')))
Example usage in Dropbox:
def inputStream = 'dbx://path/to/foo.txt'.vfsGetInputStream([ 'applicationName': 'ApplicationName/Version', 'accessToken': 'your-access-token', 'userLocale': Locale.getDefault(), 'autoRetry': true, 'maxRetries': 5], inputStream -> Files.copy(${inputStream}, Paths.get('path', 'to', 'target')))
Example usage in Google Drive:
def inputStream = 'gdv://path/to/foo.txt'.vfsGetInputStream([ 'applicationName': 'ApplicationName/Version', 'clientId': 'your-client-id', 'clientSecret': 'your-client-secret', 'refreshToken': 'your-refresh-token', 'accessToken': 'your-access-token', 'autoRetry': true], inputStream -> Files.copy(${inputStream}, Paths.get('path', 'to', 'target')))
Example usage in Amazon S3:
def inputStream = 's3://path/to/foo.txt'.vfsGetInputStream([ 'accesskey': 'your-access-key', 'secretkey': 'your-secret-key', 'region': 'your-region', 'bucketName': 'your-bucket-name'], inputStream -> Files.copy(${inputStream}, Paths.get('path', 'to', 'target')))
Example usage in OneDrive:
def inputStream = 'od://path/to/foo.txt'.vfsGetInputStream([ 'accessToken': 'your-access-token', 'refreshToken': 'your-refresh-token', 'clientId': 'your-clientId', 'clientSecret': 'your-clientSecret', 'redirectUri': 'your-redirect-uri'], inputStream -> Files.copy(${inputStream}, Paths.get('path', 'to', 'target')))
- Parameters:
url
- the URL to download the remote file fromproperties
- optional properties for the requestclosure
- code to execute after fetching the stream; could benull
- Throws:
ToroException
- if an error occurs while fetching the stream; ifclosure
has more than one parameter- Since:
- 1.0
- See Also:
vfsGetInputStream(String)
,vfsGetInputStream(String, Closure)
,vfsGetInputStream(String, Map)
-
vfsGetInputStream
public static void vfsGetInputStream(String url, Closure closure) throws ToroException
Executes a closure upon fetching the stream of a file that's on a virtual file system.
The stream will be closed once the closure has finished executing. Supported file systems are:
- Local
- HTTP
- HTTPS
- FTP
- FTPS
- SFTP
Example usages:
def copy = {inputStream -> Files.copy(${inputStream}, Paths.get('path', 'to', 'target'))} 'file://path/to/local-file.txt'.vfsGetInputStream(copy) 'http://www.home.com/remote-file.txt'.vfsGetInputStream(copy) 'https://www.secure-home.com/remote-file.txt'.vfsGetInputStream(copy) 'ftp://login:password@127.0.0.1/home/login/remote-file.txt'.vfsGetInputStream(copy) 'ftps://login:password@127.0.0.1/home/login/remote-file.txt'.vfsGetInputStream(copy) 'sftp://login:password@127.0.0.1/home/login/remote-file.txt'.vfsGetInputStream(copy)
- Parameters:
url
- the URL to download the remote file fromclosure
- code to execute after fetching the stream; could benull
- Throws:
ToroException
- if an error occurs while fetching the stream; ifclosure
has more than one parameter- Since:
- 1.0
- See Also:
vfsGetInputStream(String)
,vfsGetInputStream(String, Map)
,vfsGetInputStream(String, Map, Closure)
-
vfsGetBytes
public static byte[] vfsGetBytes(String url) throws ToroException
Gets the byte array content of a file that's on a virtual file system.
Supported file systems are:
- Local
- HTTP
- HTTPS
- FTP
- FTPS
- SFTP
Example usages:
bytes = 'file://path/to/local-file.txt'.vfsGetBytes() bytes = 'http://www.home.com/remote-file.txt'.vfsGetBytes() bytes = 'https://www.secure-home.com/remote-file.txt'.vfsGetBytes() bytes = 'ftp://login:password@127.0.0.1/home/login/remote-file.txt'.vfsGetBytes() bytes = 'ftps://login:password@127.0.0.1/home/login/remote-file.txt'.vfsGetBytes() bytes = 'sftp://login:password@127.0.0.1/home/login/remote-file.txt'.vfsGetBytes()
- Parameters:
url
- the URL to download the remote file from- Returns:
- the content of the remote file
- Throws:
ToroException
- if an error occurs during this operation- Since:
- 1.0
-
vfsGetBytes
public static byte[] vfsGetBytes(String url, Map properties) throws ToroException
Gets the stream of a file that's on a virtual file system.
Supported file systems are:
- Local
- HTTP
- HTTPS
- FTP
- FTPS
- SFTP
- Dropbox - requires an access token; optional properties include the application name, user locale, auto-retry (that is, if auto-retry is enabled), max retries (if auto-retry is enabled, default is 3)
- Google Drive - requires an access token; a refresh token may also be specified but the client ID
and client secret must be defined as well; other optional properties include the application name and
auto-retry
Note:Use the OAuth 2.0 for the required
properties
- Amazon S3 - requires an access token, secret key, region and bucket name
- OneDrive - requires an access token, refresh token, client ID, client secret, and redirect uri. only the access token is used when sending authenticated request, and the rest are required for refreshing the access token when it expires
The possible entries in the
properties
map varies depending on the target virtual file system. But in general, for requests that need an access token, the following maps are accepted:['credential': ['accessToken': 'your-access-token']] ['credential': new OauthTokenAuthenticator('your-access-token')]
And if a username and password must be specified, the user can use a map like:
['credential': ['username': 'your-user-name', 'password': 'your-password', 'domain':'www.your-domain.com']]
Example usage in FTP:
def bytes = 'ftp://login:password@127.0.0.1/home/login/remote-file.txt'.vfsGetBytes( [ssl:"false", passive:"true"])
Example usage in Dropbox:
def bytes = 'dbx://path/to/foo.txt'.vfsGetBytes([ 'applicationName': 'ApplicationName/Version', 'accessToken': 'your-access-token', 'userLocale': Locale.getDefault(), 'autoRetry': true, 'maxRetries': 5])
Example usage in Google Drive:
def bytes = 'gdv://path/to/foo.txt'.vfsGetBytes([ 'applicationName': 'ApplicationName/Version', 'clientId': 'your-client-id', 'clientSecret': 'your-client-secret', 'refreshToken': 'your-refresh-token', 'accessToken': 'your-access-token', 'autoRetry': true])
Example usage in Amazon S3:
def bytes = 's3://path/to/foo.txt'.vfsGetBytes([ 'accesskey': 'your-access-key', 'secretkey': 'your-secret-key', 'region': 'your-region', 'bucketName': 'your-bucket-name'])
Example usage in OneDrive:
def bytes = 'od://path/to/foo.txt'.vfsGetBytes([ 'accessToken': 'your-access-token', 'refreshToken': 'your-refresh-token', 'clientId': 'your-clientId', 'clientSecret': 'your-clientSecret', 'redirectUri': 'your-redirect-uri'])
- Parameters:
url
- the URL to download the remote file fromproperties
- optional properties for the request- Returns:
- the content of the remote file
- Throws:
ToroException
- if an error occurs during this operation- Since:
- 1.0
-
vfsGetFile
public static File vfsGetFile(String url, String filename) throws ToroException, IOException
Gets the content of a file that's on a virtual file system and writes it to the given file.
Supported file systems are:
- Local
- HTTP
- HTTPS
- FTP
- FTPS
- SFTP
Example usages:
'file://path/to/local-file.txt'.vfsGetFile( '/tmp/data.txt' ) 'http://www.home.com/remote-file.txt'.vfsGetFile( '/tmp/data.txt' ) 'https://www.secure-home.com/remote-file.txt'.vfsGetFile( '/tmp/data.txt' ) 'ftp://login:password@127.0.0.1/home/login/remote-file.txt'.vfsGetFile( '/tmp/data.txt' ) 'ftps://login:password@127.0.0.1/home/login/remote-file.txt'.vfsGetFile( '/tmp/data.txt' ) 'sftp://login:password@127.0.0.1/home/login/remote-file.txt'.vfsGetFile( '/tmp/data.txt' )
- Parameters:
url
- the URL to download the remote file from- Returns:
- the file object
- Throws:
ToroException
- if an error occurs during this operationIOException
- Since:
- 1.0
-
vfsGetFile
public static File vfsGetFile(String url, String filename, Map properties) throws ToroException, IOException
Writes a file from a virtual file system to the local file system.
Supported file systems are:
- Local
- HTTP
- HTTPS
- FTP
- FTPS
- SFTP
- Dropbox - requires an access token; optional properties include the application name, user locale, auto-retry (that is, if auto-retry is enabled), max retries (if auto-retry is enabled, default is 3)
- Google Drive - requires an access token; a refresh token may also be specified but the client ID
and client secret must be defined as well; other optional properties include the application name and
auto-retry
Note:Use the OAuth 2.0 for the required
properties
- Amazon S3 - requires an access token, secret key, region and bucket name
- OneDrive - requires an access token, refresh token, client ID, client secret, and redirect uri. only the access token is used when sending authenticated request, and the rest are required for refreshing the access token when it expires
The possible entries in the
properties
map varies depending on the target virtual file system. But in general, for requests that need an access token, the following maps are accepted:['credential': ['accessToken': 'your-access-token']] ['credential': new OauthTokenAuthenticator('your-access-token')]
And if a username and password must be specified, the user can use a map like:
['credential': ['username': 'your-user-name', 'password': 'your-password', 'domain':'www.your-domain.com']]
Example usage in FTP:
def bytes = 'ftp://login:password@127.0.0.1/home/login/remote-file.txt'.vfsGetBytes( [ssl:"false", passive:"true"])
Example usage in Dropbox:
def bytes = 'dbx://path/to/foo.txt'.vfsGetFile( '/tmp/hello.txt',[ 'applicationName': 'ApplicationName/Version', 'accessToken': 'your-access-token', 'userLocale': Locale.getDefault(), 'autoRetry': true, 'maxRetries': 5])
Example usage in Google Drive:
def bytes = 'gdv://path/to/foo.txt'.vfsGetFile( '/tmp/hello.txt',[ 'applicationName': 'ApplicationName/Version', 'clientId': 'your-client-id', 'clientSecret': 'your-client-secret', 'refreshToken': 'your-refresh-token', 'accessToken': 'your-access-token', 'autoRetry': true])
Example usage in Amazon S3:
def bytes = 's3://path/to/foo.txt'.vfsGetFile( '/tmp/hello.txt',[ 'accesskey': 'your-access-key', 'secretkey': 'your-secret-key', 'region': 'your-region', 'bucketName': 'your-bucket-name'])
Example usage in OneDrive:
File f = 'od://path/to/foo.txt'.vfsGetFile( '/tmp/hello.txt',[ 'accessToken': 'your-access-token', 'refreshToken': 'your-refresh-token', 'clientId': 'your-clientId', 'clientSecret': 'your-clientSecret', 'redirectUri': 'your-redirect-uri'])
- Parameters:
url
- the URL to download the remote file fromfilename
- the name of the file to write the data toproperties
- optional properties for the request- Returns:
- the content of the remote file
- Throws:
ToroException
- if an error occurs during this operationIOException
- Since:
- 1.0
-
file
public static org.apache.commons.vfs2.FileObject file(String url) throws ToroException
Gets the
FileObject
of a file that's on a virtual file system.Supported file systems are:
- Local
- HTTP
- HTTPS
- FTP
- FTPS
- SFTP
Example usages:
file = 'file://path/to/local-file.txt'.file() file = 'http://www.home.com/remote-file.txt'.file() file = 'https://www.secure-home.com/remote-file.txt'.file() file = 'ftp://login:password@127.0.0.1/home/login/remote-file.txt'.file() file = 'ftps://login:password@127.0.0.1/home/login/remote-file.txt'.file() file = 'sftp://login:password@127.0.0.1/home/login/remote-file.txt'.file()
- Parameters:
url
- the URL to download the remote file from- Returns:
- the content of the remote file
- Throws:
ToroException
- if an error occurs during this operation- Since:
- 1.0
-
file
public static org.apache.commons.vfs2.FileObject file(String url, Map properties) throws ToroException
Gets the
FileObject
of a file that's on a virtual file system.Supported file systems are:
- Local
- HTTP
- HTTPS
- FTP
- FTPS
- SFTP
- Dropbox - requires an access token; optional properties include the application name, user locale, auto-retry (that is, if auto-retry is enabled), max retries (if auto-retry is enabled, default is 3)
- Google Drive - requires an access token; a refresh token may also be specified but the client ID
and client secret must be defined as well; other optional properties include the application name and
auto-retry
Note:Use the OAuth 2.0 for the required
properties
The possible entries in the
properties
map varies depending on the target virtual file system. But in general, for requests that need an access token, the following maps are accepted:['credential': ['accessToken': 'your-access-token']] ['credential': new OauthTokenAuthenticator('your-access-token')]
And if a username and password must be specified, the user can use a map like:
['credential': ['username': 'your-user-name', 'password': 'your-password', 'domain':'www.your-domain.com']]
Example usage in FTP:
def file = 'ftp://login:password@127.0.0.1/home/login/remote-file.txt'.file([ssl:"false", passive:"true"])
Example usage in Dropbox:
def file = 'dbx://path/to/foo.txt'.file([ 'applicationName': 'ApplicationName/Version', 'accessToken': 'your-access-token', 'userLocale': Locale.getDefault(), 'autoRetry': true, 'maxRetries': 5])
Example usage in Google Drive:
def file = 'gdv://path/to/foo.txt'.file([ 'applicationName': 'ApplicationName/Version', 'clientId': 'your-client-id', 'clientSecret': 'your-client-secret', 'refreshToken': 'your-refresh-token', 'accessToken': 'your-access-token', 'autoRetry': true])
Example usage in Amazon S3:
def file = 's3://path/to/foo.txt'.file([ 'accesskey': 'your-access-key', 'secretkey': 'your-secret-key', 'region': 'your-region', 'bucketName': 'your-bucket-name'])
Example usage in OneDrive:
def file = 'od://path/to/foo.txt'.file([ 'accessToken': 'your-access-token', 'refreshToken': 'your-refresh-token', 'clientId': 'your-clientId', 'clientSecret': 'your-clientSecret', 'redirectUri': 'your-redirect-uri'])
- Parameters:
url
- the URL to download the remote file fromproperties
- optional properties for the request- Returns:
- the content of the remote file
- Throws:
ToroException
- if an error occurs during this operation- Since:
- 1.0
-
send
public static void send(String url, Map properties, Reader data, List<javax.activation.DataSource> attachment) throws ToroException, IOException
Sends bytes of data to a remote location.
Supported file systems are:
- Local
- FTP
- FTPS
- SFTP
- Dropbox - requires an access token; optional properties include the application name, user locale, auto-retry (that is, if auto-retry is enabled), max retries (if auto-retry is enabled, default is 3)
- Google Drive - requires an access token; a refresh token may also be specified but the client ID
and client secret must be defined as well; other optional properties include the application name and
auto-retry
Note:Use the OAuth 2.0 for the required
properties
- Amazon S3 - requires an access token, secret key, region and bucket name
- OneDrive - requires an access token, refresh token, client ID, client secret, and redirect uri. only the access token is used when sending authenticated request, and the rest are required for refreshing the access token when it expires
The possible entries in the
properties
map varies depending on the target virtual file system. But in general, for requests that need an access token, the following maps are accepted:['credential': ['accessToken': 'your-access-token']] ['credential': new OauthTokenAuthenticator('your-access-token')]
And if a username and password must be specified, the user can use a map like:
['credential': ['username': 'your-user-name', 'password': 'your-password', 'domain':'www.your-domain.com']]
Example usage in FTP:
'ftp://login:password@127.0.0.1/home/login/remote-file.txt'.send( [ssl:"false", passive:"true"], 'The quick brown fox jumps over the lazy dog.'.bytes(), null)
Example usage in Dropbox:
'dbx://path/to/foo.txt'.send([ 'applicationName': 'ApplicationName/Version', 'accessToken': 'your-access-token', 'userLocale': Locale.getDefault(), 'autoRetry': true, 'maxRetries': 5], 'The quick brown fox jumps over the lazy dog.'.bytes(), null)
Example usage in Google Drive:
'gdv://path/to/foo.txt'.send([ 'applicationName': 'ApplicationName/Version', 'clientId': 'your-client-id', 'clientSecret': 'your-client-secret', 'refreshToken': 'your-refresh-token', 'accessToken': 'your-access-token', 'autoRetry: true'], 'The quick brown fox jumps over the lazy dog.'.bytes(), null)
Example usage in Amazon S3:
's3://path/to/foo.txt'.send([ 'accesskey': 'your-access-key', 'secretkey': 'your-secret-key', 'region': 'your-region', 'bucketName': 'your-bucket-name'], 'The quick brown fox jumps over the lazy dog'.bytes(), null)
Example usage in OneDrive:
'od://path/to/foo.txt'.send([ 'accessToken': 'your-access-token', 'refreshToken': 'your-refresh-token', 'clientId': 'your-clientId', 'clientSecret': 'your-clientSecret', 'redirectUri': 'your-redirect-uri'], 'the quick brown fox jumps over the lazy dog'.bytes(), null)
For sending emails, the properties map must contain a to value. cc and bcc are optional.
def emailBody = ... def emailAttachments = ... 'smtp://user%40gmail.com:password@smtp.gmail.com:587/here%is%your%report'.send( [to: 'friend@gmail.com'], emailBody, emailAttachments);
- Parameters:
url
- the URL to download the remote file fromproperties
- optional properties for the request, must contain a 'to' valuedata
- the data to send (if data is to be sent to an email, this is the body of the email)attachment
- email attachments; only used if data is to be sent via email, should benull
otherwise- Throws:
ToroException
- ifurl
is empty; ifdata
is empty; if an email is to be sent but theto
property is empty; or if any other error occurs during this operationIOException
- Since:
- 1.0
- See Also:
send(String, byte[])
,sendTo(byte[], String)
-
send
public static byte[] send(String url, byte[] data) throws ToroException, IOException
Sends bytes of data to a remote location.
Supported file systems are:
- Local
- FTP
- FTPS
- SFTP
Example usages:
def content = 'The quick brown fox jumps over the lazy dog.'.bytes() 'file://path/to/local-file.txt'.send(content) 'ftp://login:password@127.0.0.1/home/login/remote-file.txt'.send(content) 'ftps://login:password@127.0.0.1/home/login/remote-file.txt'.send(content) 'sftp://login:password@127.0.0.1/home/login/remote-file.txt'.send(content)
- Parameters:
url
- the URL to send the data todata
- the data to send- Returns:
- the data array passed in
- Throws:
ToroException
- ifurl
is empty; ifdata
is empty; if an email is to be sent but theto
property is empty; or if any other error occurs during this operationIOException
- Since:
- 1.0
- See Also:
sendTo(String, Map, byte[])
-
send
public static byte[] send(String url, byte[] data, Map properties) throws ToroException, IOException
Sends bytes of data to a remote location.
Supported file systems are:
- Local
- FTP
- FTPS
- SFTP
- Dropbox - requires an access token; optional properties include the application name, user locale, auto-retry (that is, if auto-retry is enabled), max retries (if auto-retry is enabled, default is 3)
- Google Drive - requires an access token; a refresh token may also be specified but the client ID
and client secret must be defined as well; other optional properties include the application name and
auto-retry
Note:Use the OAuth 2.0 for the required
properties
- Amazon S3 - requires an access token, secret key, region and bucket name
- OneDrive - requires an access token, refresh token, client ID, client secret, and redirect uri. only the access token is used when sending authenticated request, and the rest are required for refreshing the access token when it expires
The possible entries in the
properties
map varies depending on the target virtual file system. But in general, for requests that need an access token, the following maps are accepted:['credential': ['accessToken': 'your-access-token']] ['credential': new OauthTokenAuthenticator('your-access-token')]
And if a username and password must be specified, the user can use a map like:
['credential': ['username': 'your-user-name', 'password': 'your-password', 'domain':'www.your-domain.com']]
Example usage in FTP:
def content = 'The quick brown fox jumps over the lazy dog.'.bytes() 'ftp://login:password@127.0.0.1/home/login/remote-file.txt'.send(content, [ssl:"false", passive:"true"])
Example usage in Dropbox:
def content = 'The quick brown fox jumps over the lazy dog.'.bytes() 'dbx://path/to/foo.txt'.send(content, [ 'applicationName': 'ApplicationName/Version', 'accessToken': 'your-access-token', 'userLocale': Locale.getDefault(), 'autoRetry': true, 'maxRetries': 5])
Example usage in Google Drive:
def content = 'The quick brown fox jumps over the lazy dog.'.bytes() 'gdv://path/to/foo.txt'.send(content, [ 'applicationName': 'ApplicationName/Version', 'clientId': 'your-client-id', 'clientSecret': 'your-client-secret', 'refreshToken': 'your-refresh-token', 'accessToken': 'your-access-token', 'autoRetry': true])
Example usage in Amazon S3:
def content = 'The quick brown fox jumps over the lazy dog.'.bytes() 's3://path/to/foo.txt'.send(content, [ 'accesskey': 'your-access-key', 'secretkey': 'your-secret-key', 'region': 'your-region', 'bucketName': 'your-bucket-name'])
Example usage in OneDrive:
def content = 'The quick brown fox jumps over the lazy dog.'.bytes() 'od://path/to/foo.txt'.send(content, [ 'accessToken': 'your-access-token', 'refreshToken': 'your-refresh-token', 'clientId': 'your-clientId', 'clientSecret': 'your-clientSecret', 'redirectUri': 'your-redirect-uri'])
For sending emails:
def content = 'The quick brown fox jumps over the lazy dog.'.bytes() 'smtp://user%40gmail.com:password@smtp.gmail.com:587/here%is%your%report'.send( content, [to: 'friend@gmail.com']);
- Parameters:
url
- the URL to send the data todata
- the data to sendproperties
- optional properties for the request, must contain a 'to' value- Returns:
- the data array passed in
- Throws:
ToroException
- ifurl
is empty; ifdata
is empty; if an email is to be sent but theto
property is empty; or if any other error occurs during this operationIOException
- Since:
- 1.0
-
send
public static String send(String url, Map properties, String data) throws ToroException, IOException
Sends string to a remote location.
Supported file systems are:
- Local
- FTP
- FTPS
- SFTP
- Dropbox - requires an access token; optional properties include the application name, user locale, auto-retry (that is, if auto-retry is enabled), max retries (if auto-retry is enabled, default is 3)
- Google Drive - requires an access token; a refresh token may also be specified but the client ID
and client secret must be defined as well; other optional properties include the application name and
auto-retry
Note:Use the OAuth 2.0 for the required
properties
- Amazon S3 - requires an access token, secret key, region and bucket name
- OneDrive - requires an access token, refresh token, client ID, client secret, and redirect uri. only the access token is used when sending authenticated request, and the rest are required for refreshing the access token when it expires
The possible entries in the
properties
map varies depending on the target virtual file system. But in general, for requests that need an access token, the following maps are accepted:['credential': ['accessToken': 'your-access-token']] ['credential': new OauthTokenAuthenticator('your-access-token')]
And if a username and password must be specified, the user can use a map like:
['credential': ['username': 'your-user-name', 'password': 'your-password', 'domain':'www.your-domain.com']]
Example usage in FTP:
'ftp://login:password@127.0.0.1/home/login/remote-file.txt'.send( [ssl:"false", passive:"true"], 'The quick brown fox jumps over the lazy dog.')
Example usage in Dropbox:
'dbx://path/to/foo.txt'.send([ 'applicationName': 'ApplicationName/Version', 'accessToken': 'your-access-token', 'userLocale': Locale.getDefault(), 'autoRetry': true, 'maxRetries': 5], 'The quick brown fox jumps over the lazy dog.')
Example usage in Google Drive:
'gdv://path/to/foo.txt'.send([ 'applicationName': 'ApplicationName/Version', 'clientId': 'your-client-id', 'clientSecret': 'your-client-secret', 'refreshToken': 'your-refresh-token', 'accessToken': 'your-access-token', 'autoRetry': true], 'The quick brown fox jumps over the lazy dog.')
Example usage in Amazon S3:
's3://path/to/foo.txt'.send([ 'accesskey': 'your-access-key', 'secretkey': 'your-secret-key', 'region': 'your-region', 'bucketName': 'your-bucket-name'], 'The quick brown fox jumps over the lazy dog')
Example usage in OneDrive:
'od://path/to/foo.txt'.send([ 'accessToken': 'your-access-token', 'refreshToken': 'your-refresh-token', 'clientId': 'your-clientId', 'clientSecret': 'your-clientSecret', 'redirectUri': 'your-redirect-uri'], 'The quick brown fox jumps over the lazy dog')
For sending emails:
'smtp://user%40gmail.com:password@smtp.gmail.com:587/here%is%your%report'.send( [to: 'friend@gmail.com'], 'The quick brown fox jumps over the lazy dog.');
- Parameters:
url
- the URL to send the data todata
- the data to send (if data is to be sent to an email, this is the body of the email)properties
- optional properties for the request; could be null- Returns:
- the data string passed in
- Throws:
ToroException
- ifurl
is empty; ifdata
is empty; if an email is to be sent but theto
property is empty; or if any other error occurs during this operationIOException
- Since:
- 1.0
- See Also:
send(String, String)
-
send
public static String send(String url, Map properties, String data, List<javax.activation.DataSource> attachment) throws ToroException, IOException
Sends string to a remote location.
Supported file systems are:
- Local
- FTP
- FTPS
- SFTP
- Dropbox - requires an access token; optional properties include the application name, user locale, auto-retry (that is, if auto-retry is enabled), max retries (if auto-retry is enabled, default is 3)
- Google Drive - requires an access token; a refresh token may also be specified but the client ID and client secret must be defined as well; other optional properties include the application name and auto-retry
- Amazon S3 - requires an access token, secret key, region and bucket name
- OneDrive - requires an access token, refresh token, client ID, client secret, and redirect uri. only the access token is used when sending authenticated request, and the rest are required for refreshing the access token when it expires
The possible entries in the
properties
map varies depending on the target virtual file system. But in general, for requests that need an access token, the following maps are accepted:['credential': ['accessToken': 'your-access-token']] ['credential': new OauthTokenAuthenticator('your-access-token')]
And if a username and password must be specified, the user can use a map like:
['credential': ['username': 'your-user-name', 'password': 'your-password', 'domain':'www.your-domain.com']]
Example usage in FTP:
'ftp://login:password@127.0.0.1/home/login/remote-file.txt'.send( [ssl:"false", passive:"true"], 'The quick brown fox jumps over the lazy dog.', null)
Example usage in Dropbox:
'dbx://path/to/foo.txt'.send([ 'applicationName': 'ApplicationName/Version', 'accessToken': 'your-access-token', 'userLocale': Locale.getDefault(), 'autoRetry': true, 'maxRetries': 5], 'The quick brown fox jumps over the lazy dog.', null)
Example usage in Google Drive:
'gdv://path/to/foo.txt'.send([ 'applicationName': 'ApplicationName/Version', 'clientId': 'your-client-id', 'clientSecret': 'your-client-secret', 'refreshToken': 'your-refresh-token', 'accessToken': 'your-access-token', 'autoRetry': true], 'The quick brown fox jumps over the lazy dog.', null)
Example usage in Amazon S3:
's3://path/to/foo.txt'.send([ 'accesskey': 'your-access-key', 'secretkey': 'your-secret-key', 'region': 'your-region', 'bucketName': 'your-bucket-name'], 'The quick brown fox jumps over the lazy dog', null)
Example usage in OneDrive:
'od://path/to/foo.txt'.send([ 'accessToken': 'your-access-token', 'refreshToken': 'your-refresh-token', 'clientId': 'your-clientId', 'clientSecret': 'your-clientSecret', 'redirectUri': 'your-redirect-uri'], 'The quick brown fox jumps over the lazy dog', null)
For sending emails:
def emailBody = ... def emailAttachments = ... 'smtp://user%40gmail.com:password@smtp.gmail.com:587/here%is%your%report'.send( [to: 'friend@gmail.com'], emailBody, emailAttachments);
- Parameters:
url
- the URL to send the data todata
- the data to send (if data is to be sent to an email, this is the body of the email)properties
- optional properties for the request; could be nullattachment
- email attachments; only used if data is to be sent via email, should be null otherwise- Returns:
- the data string passed in
- Throws:
ToroException
- ifurl
is empty; ifdata
is empty; if an email is to be sent but theto
property is empty; or if any other error occurs during this operationIOException
- Since:
- 1.0
- See Also:
send(String, String)
,send(String, Map, String)
-
send
public static String send(String url, String data) throws ToroException, IOException
Sends string to a remote location.
Supported file systems are:
- Local
- FTP
- FTPS
- SFTP
Example usages:
'file://path/to/local-file.txt'.send('The quick brown fox jumps over the lazy dog.') 'ftp://login:password@127.0.0.1/home/login/remote-file.txt'.send('The quick brown fox jumps over the lazy dog.') 'ftps://login:password@127.0.0.1/home/login/remote-file.txt'.send('The quick brown fox jumps over the lazy dog.') 'sftp://login:password@127.0.0.1/home/login/remote-file.txt'.send('The quick brown fox jumps over the lazy dog.')
- Parameters:
url
- the URL to send the data todata
- the data to send- Returns:
- the data sent
- Throws:
ToroException
- ifdata
is empty; ifurl
is empty; or if any other error occurs during this operationIOException
- Since:
- 1.0
- See Also:
send(String, Map, String)
,sendTo(String, String, Map)
-
send
public static File send(String url, Map properties, File file) throws ToroException
Sends a file to a remote location.
Supported file systems are:
- Local
- FTP
- FTPS
- SFTP
- Dropbox - requires an access token; optional properties include the application name, user locale, auto-retry (that is, if auto-retry is enabled), max retries (if auto-retry is enabled, default is 3)
- Google Drive - requires an access token; a refresh token may also be specified but the client ID
and client secret must be defined as well; other optional properties include the application name and
auto-retry
Note:Use the OAuth 2.0 for the required
properties
- Amazon S3 - requires an access token, secret key, region and bucket name
- OneDrive - requires an access token, refresh token, client ID, client secret, and redirect uri. only the access token is used when sending authenticated request, and the rest are required for refreshing the access token when it expires
The possible entries in the
properties
map varies depending on the target virtual file system. But in general, for requests that need an access token, the following maps are accepted:['credential': ['accessToken': 'your-access-token']] ['credential': new OauthTokenAuthenticator('your-access-token')]
And if a username and password must be specified, the user can use a map like:
['credential': ['username': 'your-user-name', 'password': 'your-password', 'domain':'www.your-domain.com']]
Example usage in FTP:
def file = ... 'ftp://login:password@127.0.0.1/home/login/remote-file.txt'.send([ssl:"false", passive:"true"], file)
Example usage in Dropbox:
def file = ... 'dbx://path/to/foo.txt'.send([ 'applicationName': 'ApplicationName/Version', 'accessToken': 'your-access-token', 'userLocale': Locale.getDefault(), 'autoRetry': true, 'maxRetries': 5], file)
Example usage in Google Drive:
def file = ... 'gdv://path/to/foo.txt'.send([ 'applicationName': 'ApplicationName/Version', 'clientId': 'your-client-id', 'clientSecret': 'your-client-secret', 'refreshToken': 'your-refresh-token', 'accessToken': 'your-access-token', 'autoRetry': true], file)
Example usage in Amazon S3:
def file = ... 's3://path/to/foo.txt'.send([ 'accesskey': 'your-access-key', 'secretkey': 'your-secret-key', 'region': 'your-region', 'bucketName': 'your-bucket-name'], file)
Example usage in OneDrive:
def file = ... 'od://path/to/foo.txt'.send([ 'accessToken': 'your-access-token', 'refreshToken': 'your-refresh-token', 'clientId': 'your-clientId', 'clientSecret': 'your-clientSecret', 'redirectUri': 'your-redirect-uri'], file)
For sending emails:
def file = ... 'smtp://user%40gmail.com:password@smtp.gmail.com:587/here%is%your%report'.send([to: 'friend@gmail.com'], file);
- Parameters:
url
- the URL to send the data toproperties
- optional properties for the request; could be nullfile
- the data to send (if data is to be sent to an email, this is the body of the email)- Returns:
- the file sent
- Throws:
ToroException
- ifurl
is empty; if file is empty, if an email is to be sent but theto
property is empty; or if any other error occurs during this operation- Since:
- 1.0
-
send
public static File send(String url, File file) throws ToroException
Sends a file to a remote location.
Supported file systems are:
- Local
- FTP
- FTPS
- SFTP
Example usages:
def file = ... 'file://path/to/local-file.txt'.send(file) 'ftp://login:password@127.0.0.1/home/login/remote-file.txt'.send(file) 'ftps://login:password@127.0.0.1/home/login/remote-file.txt'.send(file) 'sftp://login:password@127.0.0.1/home/login/remote-file.txt'.send(file)
- Parameters:
url
- the URL to send the file tofile
- the file to send- Returns:
- the file sent
- Throws:
ToroException
- ifurl
is empty; iffile
ends up having no data, or if any other error occurs during this operation- Since:
- 1.0
-
send
public static void send(String url, Map properties, InputStream is) throws ToroException
Sends a stream to a remote location.
The stream is closed after this operation. Supported file systems are:
- Local
- FTP
- FTPS
- SFTP
- Dropbox - requires an access token; optional properties include the application name, user locale, auto-retry (that is, if auto-retry is enabled), max retries (if auto-retry is enabled, default is 3)
- Google Drive - requires an access token; a refresh token may also be specified but the client ID
and client secret must be defined as well; other optional properties include the application name and
auto-retry
Note:Use the OAuth 2.0 for the required
properties
- Amazon S3 - requires an access token, secret key, region and bucket name
- OneDrive - requires an access token, refresh token, client ID, client secret, and redirect uri. only the access token is used when sending authenticated request, and the rest are required for refreshing the access token when it expires
The possible entries in the
properties
map varies depending on the target virtual file system. But in general, for requests that need an access token, the following maps are accepted:['credential': ['accessToken': 'your-access-token']] ['credential': new OauthTokenAuthenticator('your-access-token')]
And if a username and password must be specified, the user can use a map like:
['credential': ['username': 'your-user-name', 'password': 'your-password', 'domain':'www.your-domain.com']]
Example usage in FTP:
def inputStream = ... 'ftp://login:password@127.0.0.1/home/login/remote-file.txt'.send( [ssl:"false", passive:"true"], inputStream)
Example usage in Dropbox:
def inputStream = ... 'dbx://path/to/foo.txt'.send([ 'applicationName': 'ApplicationName/Version', 'accessToken': 'your-access-token', 'userLocale': Locale.getDefault(), 'autoRetry': true, 'maxRetries': 5], inputStream)
Example usage in Google Drive:
def inputStream = ... 'gdv://path/to/foo.txt'.send([ 'applicationName': 'ApplicationName/Version', 'clientId': 'your-client-id', 'clientSecret': 'your-client-secret', 'refreshToken': 'your-refresh-token', 'accessToken': 'your-access-token', 'autoRetry': true], inputStream)
Example usage in Amazon S3:
def inputStream = ... 's3://path/to/foo.txt'.send([ 'accesskey': 'your-access-key', 'secretkey': 'your-secret-key', 'region': 'your-region', 'bucketName': 'your-bucket-name'], inputStream)
Example usage in OneDrive:
def inputStream = ... 'od://path/to/foo.txt'.send([ 'accessToken': 'your-access-token', 'refreshToken': 'your-refresh-token', 'clientId': 'your-clientId', 'clientSecret': 'your-clientSecret', 'redirectUri': 'your-redirect-uri'], inputStream)
For sending emails:
def inputStream = ... 'smtp://user%40gmail.com:password@smtp.gmail.com:587/here%is%your%report'.send( [to: 'friend@gmail.com'], inputStream);
- Parameters:
url
- the URL to send the stream tois
- the data to send (if data is to be sent to an email, this is the body of the email)properties
- optional properties for the request; could be null- Throws:
ToroException
- ifurl
is empty; ifis
turns out to be empty; if an email is to be sent but theto
property is empty; or if any other error occurs during this operation- Since:
- 1.0
-
send
public static void send(String url, InputStream is) throws ToroException
Sends stream to a remote location.
The stream is closed after this operation. Supported file systems are:
- Local
- FTP
- FTPS
- SFTP
Example usages:
def inputStream = ... 'file://path/to/local-file.txt'.send(inputStream) 'ftp://login:password@127.0.0.1/home/login/remote-file.txt'.send(inputStream) 'ftps://login:password@127.0.0.1/home/login/remote-file.txt'.send(inputStream) 'sftp://login:password@127.0.0.1/home/login/remote-file.txt'.send(inputStream)
- Parameters:
url
- the URL to send the data tois
- the stream to send- Throws:
ToroException
- ifurl
is empty; ifis
is turns out to be empty; or if any other error occurs during this operation- Since:
- 1.0
-
send
public static void send(String url, Map properties, Reader reader) throws ToroException
Sends the contents of a reader to a remote location.
Supported file systems are:
- Local
- FTP
- FTPS
- SFTP
- Dropbox - requires an access token; optional properties include the application name, user locale, auto-retry (that is, if auto-retry is enabled), max retries (if auto-retry is enabled, default is 3)
- Google Drive - requires an access token; a refresh token may also be specified but the client ID
and client secret must be defined as well; other optional properties include the application name and
auto-retry
Note:Use the OAuth 2.0 for the required
properties
- Amazon S3 - requires an access token, secret key, region and bucket name
- OneDrive - requires an access token, refresh token, client ID, client secret, and redirect uri. only the access token is used when sending authenticated request, and the rest are required for refreshing the access token when it expires
The possible entries in the
properties
map varies depending on the target virtual file system. But in general, for requests that need an access token, the following maps are accepted:['credential': ['accessToken': 'your-access-token']] ['credential': new OauthTokenAuthenticator('your-access-token')]
And if a username and password must be specified, the user can use a map like:
['credential': ['username': 'your-user-name', 'password': 'your-password', 'domain':'www.your-domain.com']]
Example usage in FTP:
def inputStream = ... 'ftp://login:password@127.0.0.1/home/login/remote-file.txt'.send( [ssl:"false", passive:"true"], inputStream)
Example usage in Dropbox:
def reader = ... 'dbx://path/to/foo.txt'.send([ 'applicationName': 'ApplicationName/Version', 'accessToken': 'your-access-token', 'userLocale': Locale.getDefault(), 'autoRetry': true, 'maxRetries': 5], reader)
Example usage in Google Drive:
def reader = ... 'gdv://path/to/foo.txt'.send([ 'applicationName': 'ApplicationName/Version', 'clientId': 'your-client-id', 'clientSecret': 'your-client-secret', 'refreshToken': 'your-refresh-token', 'accessToken': 'your-access-token', 'autoRetry': true], reader)
Example usage in Amazon S3:
def reader = ... 's3://path/to/foo.txt'.send([ 'accesskey': 'your-access-key', 'secretkey': 'your-secret-key', 'region': 'your-region', 'bucketName': 'your-bucket-name'], reader)
Example usage in OneDrive:
def reader = ... 'od://path/to/foo.txt'.send([ 'accessToken': 'your-access-token', 'refreshToken': 'your-refresh-token', 'clientId': 'your-clientId', 'clientSecret': 'your-clientSecret', 'redirectUri': 'your-redirect-uri'], reader)
For sending emails:
def reader = ... 'smtp://user%40gmail.com:password@smtp.gmail.com:587/here%is%your%report'.send( [to: 'friend@gmail.com'], reader);
- Parameters:
url
- the URL to send the stream toreader
- contains the data to be sent (if data is to be sent to an email, this is the body of the email)properties
- optional properties for the request; could be null- Throws:
ToroException
- ifurl
is empty; ifreader
turns out to be empty; if an email is to be sent but theto
property is empty; or if any other error occurs during this operation- Since:
- 1.0
-
send
public static void send(String url, Reader reader) throws ToroException
Sends the contents of a reader to a remote location.
Supported file systems are:
- Local
- FTP
- FTPS
- SFTP
Example usages:
def reader = ... 'file://path/to/local-file.txt'.send(reader) 'ftp://login:password@127.0.0.1/home/login/remote-file.txt'.send(reader) 'ftps://login:password@127.0.0.1/home/login/remote-file.txt'.send(reader) 'sftp://login:password@127.0.0.1/home/login/remote-file.txt'.send(reader)
- Parameters:
url
- the URL to send the data toreader
- contains the data to be sent- Throws:
ToroException
- ifurl
is empty; ifreader
turns out to be empty; or if any other error occurs during this operation- Since:
- 1.0
-
sendTo
public static byte[] sendTo(String url, Map properties, byte[] data) throws ToroException, IOException
Sends bytes of data to a remote location.
Supported file systems are:
- Local
- FTP
- FTPS
- SFTP
- Dropbox - requires an access token; optional properties include the application name, user locale, auto-retry (that is, if auto-retry is enabled), max retries (if auto-retry is enabled, default is 3)
- Google Drive - requires an access token; a refresh token may also be specified but the client ID
and client secret must be defined as well; other optional properties include the application name and
auto-retry
Note:Use the OAuth 2.0 for the required
properties
- Amazon S3 - requires an access token, secret key, region and bucket name
- OneDrive - requires an access token, refresh token, client ID, client secret, and redirect uri. only the access token is used when sending authenticated request, and the rest are required for refreshing the access token when it expires
The possible entries in the
properties
map varies depending on the target virtual file system. But in general, for requests that need an access token, the following maps are accepted:['credential': ['accessToken': 'your-access-token']] ['credential': new OauthTokenAuthenticator('your-access-token')]
And if a username and password must be specified, the user can use a map like:
['credential': ['username': 'your-user-name', 'password': 'your-password', 'domain':'www.your-domain.com']]
Example usage in FTP:
'ftp://login:password@127.0.0.1/home/login/remote-file.txt'.send( [ssl:"false", passive:"true"], 'The quick brown fox jumps over the lazy dog.'.bytes())
Example usage in Dropbox:
'dbx://path/to/foo.txt'.sendTo([ 'applicationName': 'ApplicationName/Version', 'accessToken': 'your-access-token', 'userLocale': Locale.getDefault(), 'autoRetry': true, 'maxRetries': 5], 'The quick brown fox jumps over the lazy dog.'.bytes())
Example usage in Google Drive:
'gdv://path/to/foo.txt'.sendTo([ 'applicationName': 'ApplicationName/Version', 'clientId': 'your-client-id', 'clientSecret': 'your-client-secret', 'refreshToken': 'your-refresh-token', 'accessToken': 'your-access-token', 'autoRetry': true], 'The quick brown fox jumps over the lazy dog.'.bytes())
Example usage in Amazon S3:
's3://path/to/foo.txt'.sendTo([ 'accesskey': 'your-access-key', 'secretkey': 'your-secret-key', 'region': 'your-region', 'bucketName': 'your-bucket-name'], 'The quick brown fox jumps over the lazy dog'.bytes())
Example usage in OneDrive:
'od://path/to/foo.txt'.sendTo([ 'accessToken': 'your-access-token', 'refreshToken': 'your-refresh-token', 'clientId': 'your-clientId', 'clientSecret': 'your-clientSecret', 'redirectUri': 'your-redirect-uri'], 'The quick brown fox jumps over the lazy dog'.bytes())
For sending emails:
'smtp://user%40gmail.com:password@smtp.gmail.com:587/here%is%your%report'.sendTo( [to: 'friend@gmail.com'], 'The quick brown fox jumps over the lazy dog.'.bytes());
- Parameters:
url
- the URL to download the remote file fromproperties
- optional properties for the request; could be nulldata
- the data to send (if data is to be sent to an email, this is the body of the email)- Returns:
- the data array passed in
- Throws:
ToroException
- ifurl
is empty; ifdata
is empty; if an email is to be sent but theto
property is empty; or if any other error occurs during this operationIOException
- Since:
- 1.0
- See Also:
send(String, byte[])
,sendTo(String, Map, byte[])
-
sendTo
public static byte[] sendTo(byte[] data, String url) throws ToroException, IOException
Sends bytes of data to a remote location.
Supported file systems are:
- Local
- FTP
- FTPS
- SFTP
Example usages:
def content = 'The quick brown fox jumps over the lazy dog.'.bytes() content.sendTo('file://path/to/local-file.txt') content.sendTo('ftp://login:password@127.0.0.1/home/login/remote-file.txt') content.sendTo('ftps://login:password@127.0.0.1/home/login/remote-file.txt') content.sendTo('sftp://login:password@127.0.0.1/home/login/remote-file.txt') content.sendTo('smtp://user%40gmail.com:password@smtp.gmail.com:587/here%is%your%report');
- Parameters:
data
- the data to sendurl
- the URL to send the data to- Returns:
- the data array passed in
- Throws:
ToroException
- ifurl
is empty; ifdata
is empty; if an email is to be sent but theto
property is empty; or if any other error occurs during this operationIOException
- Since:
- 1.0
- See Also:
send(String, byte[])
-
sendTo
public static String sendTo(String data, String url, Map properties) throws ToroException
Sends string to a remote location.
Supported file systems are:
- Local
- FTP
- FTPS
- SFTP
- Dropbox - requires an access token; optional properties include the application name, user locale, auto-retry (that is, if auto-retry is enabled), max retries (if auto-retry is enabled, default is 3)
- Google Drive - requires an access token; a refresh token may also be specified but the client ID
and client secret must be defined as well; other optional properties include the application name and
auto-retry
Note:Use the OAuth 2.0 for the required
properties
- Amazon S3 - requires an access token, secret key, region and bucket name
- OneDrive - requires an access token, refresh token, client ID, client secret, and redirect uri. only the access token is used when sending authenticated request, and the rest are required for refreshing the access token when it expires
The possible entries in the
properties
map varies depending on the target virtual file system. But in general, for requests that need an access token, the following maps are accepted:['credential': ['accessToken': 'your-access-token']] ['credential': new OauthTokenAuthenticator('your-access-token')]
And if a username and password must be specified, the user can use a map like:
['credential': ['username': 'your-user-name', 'password': 'your-password', 'domain':'www.your-domain.com']]
Example usage in FTP:
'The quick brown fox jumps over the lazy dog.'.sendTo( 'ftp://login:password@127.0.0.1/home/login/remote-file.txt', [ssl:"false", passive:"true"])
Example usage in Dropbox:
'The quick brown fox jumps over the lazy dog.'.sendTo('dbx://path/to/foo.txt', [ 'applicationName': 'ApplicationName/Version', 'accessToken': 'your-access-token', 'userLocale': Locale.getDefault(), 'autoRetry': true, 'maxRetries': 5])
Example usage in Google Drive:
'The quick brown fox jumps over the lazy dog.'.sendTo('gdv://path/to/foo.txt', [ 'applicationName': 'ApplicationName/Version', 'clientId': 'your-client-id', 'clientSecret': 'your-client-secret', 'refreshToken': 'your-refresh-token', 'accessToken': 'your-access-token', 'autoRetry': true])
Example usage in Amazon S3:
'The quick brown fox jumps over the lazy dog'.send('s3://path/to/foo.txt', [ 'accesskey': 'your-access-key', 'secretkey': 'your-secret-key', 'region': 'your-region', 'bucketName': 'your-bucket-name'])
Example usage in OneDrive:
'The quick brown fox jumps over the lazy dog'.send('od://path/to/foo.txt',[ 'accessToken': 'your-access-token', 'refreshToken': 'your-refresh-token', 'clientId': 'your-clientId', 'clientSecret': 'your-clientSecret', 'redirectUri': 'your-redirect-uri'])
For sending emails:
'The quick brown fox jumps over the lazy dog.'.sendTo( 'smtp://user%40gmail.com:password@smtp.gmail.com:587/here%is%your%report', [to: 'friend@gmail.com']);
- Parameters:
data
- the data to send (if data is to be sent to an email, this is the body of the email)url
- the URL to send the data toproperties
- optional properties for the request; could be null- Returns:
- the data string passed in
- Throws:
ToroException
- ifdata
is empty; ifurl
is empty; if an email is to be sent but theto
property is empty; or if any other error occurs during this operation- Since:
- 1.0
- See Also:
sendTo(String, String)
,send(String, Map, String)
-
sendTo
public static String sendTo(String data, String url) throws ToroException
Sends string to a remote location.
Supported file systems are:
- Local
- FTP
- FTPS
- SFTP
Example usages:
'The quick brown fox jumped.'.sendTo('file://path/to/local-file.txt') 'The quick brown fox jumped.'.sendTo('ftp://login:password@127.0.0.1/home/login/remote-file.txt') 'The quick brown fox jumped.'.sendTo('ftps://login:password@127.0.0.1/home/login/remote-file.txt') 'The quick brown fox jumped.'.sendTo('sftp://login:password@127.0.0.1/home/login/remote-file.txt')
- Parameters:
data
- the data to sendurl
- the URL to send the data to- Returns:
- the data sent
- Throws:
ToroException
- ifdata
is empty; ifurl
is empty; or if any other error occurs during this operation- Since:
- 1.0
- See Also:
send(String, String)
,sendTo(String, String, Map)
-
sendTo
public static File sendTo(File file, String url, Map properties) throws ToroException
Sends a file to a remote location.
Supported file systems are:
- Local
- FTP
- FTPS
- SFTP
- Dropbox - requires an access token; optional properties include the application name, user locale, auto-retry (that is, if auto-retry is enabled), max retries (if auto-retry is enabled, default is 3)
- Google Drive - requires an access token; a refresh token may also be specified but the client ID
and client secret must be defined as well; other optional properties include the application name and
auto-retry
Note:Use the OAuth 2.0 for the required
properties
- Amazon S3 - requires an access token, secret key, region and bucket name
- OneDrive - requires an access token, refresh token, client ID, client secret, and redirect uri. only the access token is used when sending authenticated request, and the rest are required for refreshing the access token when it expires
The possible entries in the
properties
map varies depending on the target virtual file system. But in general, for requests that need an access token, the following maps are accepted:['credential': ['accessToken': 'your-access-token']] ['credential': new OauthTokenAuthenticator('your-access-token')]
And if a username and password must be specified, the user can use a map like:
['credential': ['username': 'your-user-name', 'password': 'your-password', 'domain':'www.your-domain.com']]
Example usage in FTP:
def file = ... file.sendTo('ftp://login:password@127.0.0.1/home/login/remote-file.txt', [ssl:"false", passive:"true"])
Example usage in Dropbox:
def file = ... file.sendTo('dbx://path/to/foo.txt', [ 'applicationName': 'ApplicationName/Version', 'accessToken': 'your-access-token', 'userLocale': Locale.getDefault(), 'autoRetry': true, 'maxRetries': 5])
Example usage in Google Drive:
def file = ... file.sendTo('gdv://path/to/foo.txt', [ 'applicationName': 'ApplicationName/Version', 'clientId': 'your-client-id', 'clientSecret': 'your-client-secret', 'refreshToken': 'your-refresh-token', 'accessToken': 'your-access-token', 'autoRetry': true])
Example usage in Amazon S3:
def file = ... file.sendTo('s3://path/to/foo.txt',[ 'accesskey': 'your-access-key', 'secretkey': 'your-secret-key', 'region': 'your-region', 'bucketName': 'your-bucket-name'])
Example usage in OneDrive:
def file = ... file.sendTo('od://path/to/foo.txt', [ 'accessToken': 'your-access-token', 'refreshToken': 'your-refresh-token', 'clientId': 'your-clientId', 'clientSecret': 'your-clientSecret', 'redirectUri': 'your-redirect-uri'])
For sending emails:
def file = ... file.sendTo('smtp://user%40gmail.com:password@smtp.gmail.com:587/here%is%your%report', [to: 'friend@gmail.com'])
- Parameters:
file
- the data to send (if data is to be sent to an email, this is the body of the email)url
- the URL to send the data toproperties
- optional properties for the request; could be null- Returns:
- the file sent
- Throws:
ToroException
- ifurl
is empty; iffile
is empty, if an email is to be sent but theto
property is empty; or if any other error occurs during this operation- Since:
- 1.0
-
sendTo
public static File sendTo(File file, String url) throws ToroException
Sends a file to a remote location.
Supported file systems are:
- Local
- FTP
- FTPS
- SFTP
Example usages:
def file = ... 'file://path/to/local-file.txt'.vfsGetBytes(file) 'ftp://login:password@127.0.0.1/home/login/remote-file.txt'.send(file) 'ftps://login:password@127.0.0.1/home/login/remote-file.txt'.send(file) 'sftp://login:password@127.0.0.1/home/login/remote-file.txt'.send(file)
- Parameters:
file
- the file to sendurl
- the URL to send the file to- Returns:
- the file sent
- Throws:
ToroException
- ifurl
is empty; iffile
ends up having no data, or if any other error occurs during this operation- Since:
- 1.0
-
sendTo
public static void sendTo(InputStream is, String url, Map properties) throws ToroException
Sends a stream to a remote location.
The stream is closed after this operation. Supported file systems are:
- Local
- FTP
- FTPS
- SFTP
- Dropbox - requires an access token; optional properties include the application name, user locale, auto-retry (that is, if auto-retry is enabled), max retries (if auto-retry is enabled, default is 3)
- Google Drive - requires an access token; a refresh token may also be specified but the client ID
and client secret must be defined as well; other optional properties include the application name and
auto-retry
Note:Use the OAuth 2.0 for the required
properties
- Amazon S3 - requires an access token, secret key, region and bucket name
- OneDrive - requires an access token, refresh token, client ID, client secret, and redirect uri. only the access token is used when sending authenticated request, and the rest are required for refreshing the access token when it expires
The possible entries in the
properties
map varies depending on the target virtual file system. But in general, for requests that need an access token, the following maps are accepted:['credential': ['accessToken': 'your-access-token']] ['credential': new OauthTokenAuthenticator('your-access-token')]
And if a username and password must be specified, the user can use a map like:
['credential': ['username': 'your-user-name', 'password': 'your-password', 'domain':'www.your-domain.com']]
Example usage in FTP:
def inputStream = ... inputStream.sendTo('ftp://login:password@127.0.0.1/home/login/remote-file.txt', [ssl:"false", passive:"true"])
Example usage in Dropbox:
def inputStream = ... inputStream.sendTo('dbx://path/to/foo.txt', [ 'applicationName': 'ApplicationName/Version', 'accessToken': 'your-access-token', 'userLocale': Locale.getDefault(), 'autoRetry': true, 'maxRetries': 5])
Example usage in Google Drive:
def inputStream = ... inputStream.sendTo('gdv://path/to/foo.txt', [ 'applicationName': 'ApplicationName/Version', 'clientId': 'your-client-id', 'clientSecret': 'your-client-secret', 'refreshToken': 'your-refresh-token', 'accessToken': 'your-access-token', 'autoRetry': true])
Example usage in Amazon S3:
def inputStream = ... inputStream.sendTo('s3://path/to/foo.txt',[ 'accesskey': 'your-access-key', 'secretkey': 'your-secret-key', 'region': 'your-region', 'bucketName': 'your-bucket-name'])
Example usage in OneDrive:
def inputStream = ... inputStream.sendTo('od://path/to/foo.txt', [ 'accessToken': 'your-access-token', 'refreshToken': 'your-refresh-token', 'clientId': 'your-clientId', 'clientSecret': 'your-clientSecret', 'redirectUri': 'your-redirect-uri'])
For sending emails:
def inputStream = ... inputStream.sendTo( 'smtp://user%40gmail.com:password@smtp.gmail.com:587/here%is%your%report', [to: 'friend@gmail.com']);
- Parameters:
is
- the data to send (if data is to be sent to an email, this is the body of the email)url
- the URL to send the stream toproperties
- optional properties for the request; could be null- Throws:
ToroException
- ifurl
is empty; ifis
turns out to be empty; if an email is to be sent but theto
property is empty; or if any other error occurs during this operation- Since:
- 1.0
-
sendTo
public static void sendTo(InputStream is, String url) throws ToroException
Sends stream to a remote location.
The stream is closed after this operation. Supported file systems are:
- Local
- FTP
- FTPS
- SFTP
Example usages:
def inputStream = ... inputStream.sendTo('file://path/to/local-file.txt') inputStream.sendTo('ftp://login:password@127.0.0.1/home/login/remote-file.txt') inputStream.sendTo('ftps://login:password@127.0.0.1/home/login/remote-file.txt') inputStream.sendTo('sftp://login:password@127.0.0.1/home/login/remote-file.txt')
- Parameters:
is
- the stream to sendurl
- the URL to send the data to- Throws:
ToroException
- ifurl
is empty; ifis
is turns out to be empty; or if any other error occurs during this operation- Since:
- 1.0
-
sendTo
public static void sendTo(Reader reader, String url, Map properties) throws ToroException
Sends the contents of a reader to a remote location.
Supported file systems are:
- Local
- FTP
- FTPS
- SFTP
- Dropbox - requires an access token; optional properties include the application name, user locale, auto-retry (that is, if auto-retry is enabled), max retries (if auto-retry is enabled, default is 3)
- Google Drive - requires an access token; a refresh token may also be specified but the client ID
and client secret must be defined as well; other optional properties include the application name and
auto-retry
Note:Use the OAuth 2.0 for the required
properties
- Amazon S3 - requires an access token, secret key, region and bucket name
- OneDrive - requires an access token, refresh token, client ID, client secret, and redirect uri. only the access token is used when sending authenticated request, and the rest are required for refreshing the access token when it expires
The possible entries in the
properties
map varies depending on the target virtual file system. But in general, for requests that need an access token, the following maps are accepted:['credential': ['accessToken': 'your-access-token']] ['credential': new OauthTokenAuthenticator('your-access-token')]
And if a username and password must be specified, the user can use a map like:
['credential': ['username': 'your-user-name', 'password': 'your-password', 'domain':'www.your-domain.com']]
Example usage in FTP:
def reader = ... reader.sendTo('ftp://login:password@127.0.0.1/home/login/remote-file.txt', [ssl:"false", passive:"true"])
Example usage in Dropbox:
def reader = ... reader.sendTo('dbx://path/to/foo.txt', [ 'applicationName': 'ApplicationName/Version', 'accessToken': 'your-access-token', 'userLocale': Locale.getDefault(), 'autoRetry': true, 'maxRetries': 5])
Example usage in Google Drive:
def reader = ... reader.sendTo('gdv://path/to/foo.txt', [ 'applicationName': 'ApplicationName/Version', 'clientId': 'your-client-id', 'clientSecret': 'your-client-secret', 'refreshToken': 'your-refresh-token', 'accessToken': 'your-access-token', 'autoRetry': true])
Example usage in Amazon S3:
def reader = ... reader.sendTo('s3://path/to/foo.txt', [ 'accesskey': 'your-access-key', 'secretkey': 'your-secret-key', 'region': 'your-region', 'bucketName': 'your-bucket-name'])
Example usage in OneDrive:
reader.sendTo(['od://path/to/foo.txt', 'accessToken': 'your-access-token', 'refreshToken': 'your-refresh-token', 'clientId': 'your-clientId', 'clientSecret': 'your-clientSecret', 'redirectUri': 'your-redirect-uri'])
For sending emails:
def reader = ... reader.sendTo( 'smtp://user%40gmail.com:password@smtp.gmail.com:587/here%is%your%report', [to: 'friend@gmail.com']);
- Parameters:
reader
- contains the data to be sent (if data is to be sent to an email, this is the body of the email)url
- the URL to send the stream toproperties
- optional properties for the request; could be null- Throws:
ToroException
- ifurl
is empty; ifreader
turns out to be empty; if an email is to be sent but theto
property is empty; or if any other error occurs during this operation- Since:
- 1.0
-
sendTo
public static void sendTo(Reader reader, String url) throws ToroException
Sends the contents of a reader to a remote location.
Supported file systems are:
- Local
- FTP
- FTPS
- SFTP
Example usages:
def reader = ... reader.sendTo('file://path/to/local-file.txt') reader.sendTo('ftp://login:password@127.0.0.1/home/login/remote-file.txt') reader.sendTo('ftps://login:password@127.0.0.1/home/login/remote-file.txt') reader.sendTo('sftp://login:password@127.0.0.1/home/login/remote-file.txt')
- Parameters:
url
- the URL to send the data toreader
- contains the data to be sent- Throws:
ToroException
- ifurl
is empty; ifreader
turns out to be empty; or if any other error occurs during this operation- Since:
- 1.0
-
receive
public static javax.mail.Message[] receive(String url, boolean delete) throws ToroException
Retrieve an array of unused email messages.
Example usage:
def messages = 'imaps://$username:$password@imap.gmail.com:$port/$folder'.receive()
- Parameters:
url
- the email URL to retrieve the messages fromdelete
- if set to true, deletes read messages- Returns:
- unread email messages
- Throws:
ToroException
- if any error occurs during this operation- Since:
- 1.0
-
receive
public static javax.mail.Message[] receive(String url) throws ToroException
Retrieve an array of unread email messages.
Example usage:
def messages = 'imaps://$username:$password@imap.gmail.com:$port/$folder'.receive()
- Parameters:
url
- the email URL to retrieve the messages from- Returns:
- unread email messages
- Throws:
ToroException
- if any error occurs during this operation- Since:
- 1.0
-
copyTo
public static String copyTo(String sourceUrl, String targetUrl) throws ToroException
Copy the item found in the source url to the target url.
Supported file systems are:
- Local
- FTP
- FTPS
- SFTP
Example usage:
'file://path/to/source-file.txt'.copyTo(ftp://login:password@127.0.0.1/path/to/target-file.txt')
- Parameters:
sourceUrl
- the url of the data to copytargetUrl
- the destination of the data to be copied- Returns:
- the source url
- Throws:
ToroException
- if any error occurs during this operation- Since:
- 1.0
-
vfsPut
public static void vfsPut(String url, String data) throws ToroException, IOException
Alias forsend(String, String)
.- Throws:
ToroException
IOException
- Since:
- 1.0
-
vfsPut
public static void vfsPut(String url, String data, Map properties) throws ToroException, IOException
Alias forsend(String, Map, String)
.- Throws:
ToroException
IOException
- Since:
- 1.0
-
vfsPut
public static void vfsPut(String url, byte[] data) throws ToroException, IOException
Alias forsend(String, byte[])
.- Throws:
ToroException
IOException
- Since:
- 1.0
-
vfsPut
public static void vfsPut(String url, byte[] data, Map properties) throws ToroException, IOException
Alias for {@link #send(String, byte[], Map}.- Throws:
ToroException
IOException
- Since:
- 1.0
-
vfsPut
public static void vfsPut(String url, InputStream data) throws ToroException, IOException
Alias for {@link #send(String, InputStream}.- Throws:
ToroException
IOException
- Since:
- 1.0
-
vfsPut
public static void vfsPut(String url, InputStream data, Map properties) throws ToroException, IOException
Alias forsend(String, Map, InputStream)
.- Throws:
ToroException
IOException
- Since:
- 1.0
-
getVfsFile
@GloopObjectParameter("output{\nvfsFile#io.toro.martini.vfs.VfsFile{\n}\n}") public static GloopModel getVfsFile(@GloopParameter(allowNull=false) String url, @GloopObjectParameter("vfsFileSystemOptions#io.toro.martini.vfs.VfsFileSystemOptions{\n}") GloopModel vfsFileSystemOptions, GloopExecutionContext context) throws ToroException
Gets the
FileObject
of a file that's on a virtual file system.- Parameters:
url
- the URL to download the remote file fromvfsFileSystemOptions
- optional properties for the requestcontext
- the Gloop execution context (automatically mapped by Gloop)- Returns:
- the
FileObject
of a file that's on a virtual file system - Throws:
ToroException
- if an error occurs during this operation- Since:
- 1.0
-
close
public static void close(@GloopParameter(allowNull=false) org.apache.commons.vfs2.FileObject fileObject) throws org.apache.commons.vfs2.FileSystemException
Closes aFileObject
.- Parameters:
fileObject
- theFileObject
to close- Throws:
org.apache.commons.vfs2.FileSystemException
- on error closing the file- Since:
- 1.0
-
createFile
public static void createFile(@GloopParameter(allowNull=false) org.apache.commons.vfs2.FileObject fileObject) throws org.apache.commons.vfs2.FileSystemException
Creates the provided file, if it does not exist. Also creates any ancestor folders which do not exist. This method does nothing if the file already exists and is a file.- Parameters:
fileObject
- the file to create- Throws:
org.apache.commons.vfs2.FileSystemException
- if the file already exists with the wrong type; if the parent folder is read-only; or on error creating this file or one of its ancestors- Since:
- 1.0
-
createFolder
public static void createFolder(@GloopParameter(allowNull=false) org.apache.commons.vfs2.FileObject fileObject) throws org.apache.commons.vfs2.FileSystemException
Creates the provided folder, if it does not exist. Also creates any ancestor folders which do not exist. This method does nothing if the folder already exists.- Parameters:
fileObject
- the folder to create- Throws:
org.apache.commons.vfs2.FileSystemException
- if the folder already exists with the wrong type; if the parent folder is read-only; on error creating this folder or one of its ancestors- Since:
- 1.0
-
delete
public static boolean delete(@GloopParameter(allowNull=false) org.apache.commons.vfs2.FileObject fileObject) throws org.apache.commons.vfs2.FileSystemException
Deletes a file.- Parameters:
fileObject
- the file to delete- Returns:
- true if the file has been deleted
- Throws:
org.apache.commons.vfs2.FileSystemException
- if this file is a non-empty folder; if this file is read-only; or on error deleting this file- Since:
- 1.0
-
deleteAll
public static void deleteAll(@GloopParameter(allowNull=false) org.apache.commons.vfs2.FileObject fileObject) throws org.apache.commons.vfs2.FileSystemException
Deletes a file and its children, if any.- Parameters:
fileObject
- the file to delete- Throws:
org.apache.commons.vfs2.FileSystemException
- if an error occurs- Since:
- 1.0
-
exists
public static boolean exists(@GloopParameter(allowNull=false) org.apache.commons.vfs2.FileObject fileObject) throws org.apache.commons.vfs2.FileSystemException
Determines if the provided file exists.- Parameters:
fileObject
- the file to check- Returns:
- true if the file exists; false otherwise
- Throws:
org.apache.commons.vfs2.FileSystemException
- on error determining if file exists- Since:
- 1.0
-
getChild
@GloopObjectParameter("output{\nvfsFile#io.toro.martini.vfs.VfsFile{\n}\n}") public static GloopModel getChild(@GloopParameter(allowNull=false) org.apache.commons.vfs2.FileObject fileObject, @GloopParameter(allowNull=false) String name) throws org.apache.commons.vfs2.FileSystemException
Returns the childFileObject
of the providedFileObject
. The child file is searched by name.- Parameters:
fileObject
- where to look for the child filename
- the name of the child file- Returns:
- the child file
- Throws:
org.apache.commons.vfs2.FileSystemException
- if this file does not exist, or is not a folder; or on error determining this file's children- Since:
- 1.0
-
getChildren
@GloopObjectParameter("output{\nvfsFiles#io.toro.martini.vfs.VfsFile[]{\n}\n}") public static GloopModel getChildren(@GloopParameter(allowNull=false) org.apache.commons.vfs2.FileObject fileObject) throws org.apache.commons.vfs2.FileSystemException
Gets the children of aFileObject
. The result is usually a listing of directories and files in a directory.- Parameters:
fileObject
- the file whose children will be retrieved- Returns:
- the children of
fileObject
- Throws:
org.apache.commons.vfs2.FileSystemException
- if this file does not exist, or is not a folder; or on error listing this file's children- Since:
- 1.0
-
getContent
@GloopObjectParameter("output{\nvfsContent#io.toro.martini.vfs.VfsContent{\n}\n}") public static GloopModel getContent(org.apache.commons.vfs2.FileObject fileObject) throws org.apache.commons.vfs2.FileSystemException
Get the content of the providedFileObject
.- Parameters:
fileObject
- the file- Returns:
- content of the provided file
- Throws:
org.apache.commons.vfs2.FileSystemException
- on error getting file content- Since:
- 1.0
-
getName
@GloopObjectParameter("output{\nvfsName#io.toro.martini.vfs.VfsName{\n}\n}") public static GloopModel getName(@GloopParameter(allowNull=false) org.apache.commons.vfs2.FileObject fileObject)
Get the name of the providedFileObject
.- Parameters:
fileObject
- the file- Returns:
- the name of the file
- Since:
- 1.0
-
getParent
@GloopObjectParameter("output{\nvfsFile#io.toro.martini.vfs.VfsFile{\n}\n}") public static GloopModel getParent(@GloopParameter(allowNull=false) org.apache.commons.vfs2.FileObject fileObject) throws org.apache.commons.vfs2.FileSystemException
Get the parent of aFileObject
.- Parameters:
fileObject
- the file- Returns:
- the parent of the file
- Throws:
org.apache.commons.vfs2.FileSystemException
- on error finding parent file- Since:
- 1.0
-
refresh
public static void refresh(@GloopParameter(allowNull=false) org.apache.commons.vfs2.FileObject fileObject) throws org.apache.commons.vfs2.FileSystemException
Synchronize the file with the underlying file system.- Parameters:
fileObject
- file to synchronize- Throws:
org.apache.commons.vfs2.FileSystemException
- Since:
- 1.0
-
resolveFile
@GloopObjectParameter("output{\nvfsFile#io.toro.martini.vfs.VfsFile{\n}\n}") public static GloopModel resolveFile(@GloopParameter(allowNull=false) org.apache.commons.vfs2.FileObject fileObject, @GloopParameter(allowNull=false) String path) throws org.apache.commons.vfs2.FileSystemException
Resolve a file relative to the providedFileObject
.- Parameters:
fileObject
- the file objectpath
- the path of the file to locate withinfileObject
- Returns:
- the resolved file
- Throws:
org.apache.commons.vfs2.FileSystemException
- on error parsing the path; on error finding the file- Since:
- 1.0
-
setExecutable
public static void setExecutable(org.apache.commons.vfs2.FileObject fileObject, @GloopParameter(defaultValue="false") boolean executable, @GloopParameter(defaultValue="false") boolean ownerOnly) throws org.apache.commons.vfs2.FileSystemException
Sets the executable flag of theFileObject
.- Parameters:
fileObject
- the fileexecutable
- set to true to allow read access, false to disallowownerOnly
- if true, the permission applies only to the owner; otherwise, it applies to everybody- Throws:
org.apache.commons.vfs2.FileSystemException
- on error determining if file exists- Since:
- 1.0
-
setReadable
public static void setReadable(org.apache.commons.vfs2.FileObject fileObject, @GloopParameter(defaultValue="false") boolean readable, @GloopParameter(defaultValue="false") boolean ownerOnly) throws org.apache.commons.vfs2.FileSystemException
Sets the readable flag of theFileObject
.- Parameters:
fileObject
- the filereadable
- true to allow read access, false to disallowownerOnly
- if true, the permission applies only to the owner; otherwise, it applies to everybody- Throws:
org.apache.commons.vfs2.FileSystemException
- on error determining if file exists- Since:
- 1.0
-
setWritable
public static void setWritable(org.apache.commons.vfs2.FileObject fileObject, @GloopParameter(defaultValue="false") boolean writable, @GloopParameter(defaultValue="false") boolean ownerOnly) throws org.apache.commons.vfs2.FileSystemException
Sets the writeable flag of theFileObject
.- Parameters:
fileObject
- the filewritable
- true to allow read access, false to disallowownerOnly
- if true, the permission applies only to the owner; otherwise, it applies to everybody- Throws:
org.apache.commons.vfs2.FileSystemException
- on error determining if file exists- Since:
- 1.0
-
getAttribute
public static Object getAttribute(@GloopParameter(allowNull=false) org.apache.commons.vfs2.FileContent fileContent, @GloopParameter(allowNull=false) String attrName) throws org.apache.commons.vfs2.FileSystemException
Get the attribute value of a named file attribute.- Parameters:
fileContent
- the fileattrName
- the name of the attribute to retrieve- Returns:
- found attribute value
- Throws:
org.apache.commons.vfs2.FileSystemException
- if file does not exist; if file does not support attributes- Since:
- 1.0
-
getAttributeNames
public static String[] getAttributeNames(@GloopParameter(allowNull=false) org.apache.commons.vfs2.FileContent fileContent) throws org.apache.commons.vfs2.FileSystemException
Get the attribute names of a file.- Parameters:
fileContent
- the file- Returns:
- file attribute names
- Throws:
org.apache.commons.vfs2.FileSystemException
- if file does not exist; if file does not support attributes- Since:
- 1.0
-
getFile
@GloopObjectParameter("output{\nvfsFile#io.toro.martini.vfs.VfsFile{\n}\n}") public static GloopModel getFile(@GloopParameter(allowNull=false) org.apache.commons.vfs2.FileContent fileObject)
Get theFileObject
to which the providedFileContent
belongs to- Parameters:
fileObject
- the content- Returns:
- the file where the provided content belongs to
- Since:
- 1.0
-
getInputStream
public static InputStream getInputStream(@GloopParameter(allowNull=false) org.apache.commons.vfs2.FileContent fileContent) throws org.apache.commons.vfs2.FileSystemException
Get an input stream for reading the provided file content.- Parameters:
fileContent
- the file content- Returns:
- file content input stream
- Throws:
org.apache.commons.vfs2.FileSystemException
- if the file does not exist; if file is being read, or is being written; or on error opening the stream- Since:
- 1.0
-
getLastModifiedTime
public static long getLastModifiedTime(@GloopParameter(allowNull=false) org.apache.commons.vfs2.FileContent fileContent) throws org.apache.commons.vfs2.FileSystemException
Get the time the file content was last modified. If the file doesn't exist, -1 is returned.- Parameters:
fileContent
- the file content to check- Returns:
- the time the file content was last modified; -1 if non-existent
- Throws:
org.apache.commons.vfs2.FileSystemException
- if the file does not exist; if file is being written to; or on error determining the last-modified timestamp- Since:
- 1.0
-
getOutputStream
public static OutputStream getOutputStream(@GloopParameter(allowNull=false) org.apache.commons.vfs2.FileContent fileContent) throws org.apache.commons.vfs2.FileSystemException
Gets the output stream of the file content object if it's a file.- Parameters:
fileContent
- the file content- Returns:
- the file content output stream; null if content does not belong to a file
- Throws:
org.apache.commons.vfs2.FileSystemException
- if the file is read-only; if the file is being read, or is being written; or on error opening the stream- Since:
- 1.0
-
getSize
public static long getSize(@GloopParameter(allowNull=false) org.apache.commons.vfs2.FileContent fileContent) throws org.apache.commons.vfs2.FileSystemException
Get the size of the provided file content.- Parameters:
fileContent
- the file content- Returns:
- size of file content; -1 if file doesn't exist
- Throws:
org.apache.commons.vfs2.FileSystemException
- if the file does not exist; if file is being written to; or on error determining the size- Since:
- 1.0
-
hasAttribute
public static boolean hasAttribute(@GloopParameter(allowNull=false) org.apache.commons.vfs2.FileContent fileContent, @GloopParameter(allowNull=false) String attributeName) throws org.apache.commons.vfs2.FileSystemException
Determines whether or not a file has a specific attribute.- Parameters:
fileContent
- the file contentattributeName
- the name of the attribute to check- Returns:
- true if the file has an attribute with the provided name; false otherwise
- Throws:
org.apache.commons.vfs2.FileSystemException
- if the file does not exist, or does not support attributes.- Since:
- 1.0
-
isOpen
public static boolean isOpen(@GloopParameter(allowNull=false) org.apache.commons.vfs2.FileContent fileContent) throws org.apache.commons.vfs2.FileSystemException
Checks whether or not a file is open.- Parameters:
fileContent
- the file content- Returns:
- true if file is open; false otherwise
- Throws:
org.apache.commons.vfs2.FileSystemException
- Since:
- 1.0
-
removeAttribute
public static void removeAttribute(@GloopParameter(allowNull=false) org.apache.commons.vfs2.FileContent fileContent, @GloopParameter(allowNull=false) String attributeName) throws org.apache.commons.vfs2.FileSystemException
Removes an attribute from a file- Parameters:
fileContent
- the file contentattributeName
- the name of the attribute to remove- Throws:
org.apache.commons.vfs2.FileSystemException
- if the file does not exist; if file is read-only; if file does not support attributes; or on error removing the attribute- Since:
- 1.0
-
setAttribute
public static void setAttribute(@GloopParameter(allowNull=false) org.apache.commons.vfs2.FileContent fileContent, @GloopParameter(allowNull=false) String attributeName, @GloopParameter(allowNull=false) Object value) throws org.apache.commons.vfs2.FileSystemException
Sets a file attribute's value- Parameters:
fileContent
- the file contentattributeName
- the name of the attributevalue
- the new value of the attribute- Throws:
org.apache.commons.vfs2.FileSystemException
- if the file does not exist; if file is read-only; if file does not support attributes; or on error setting the attribute- Since:
- 1.0
-
setLastModifiedTime
public static void setLastModifiedTime(@GloopParameter(allowNull=false) org.apache.commons.vfs2.FileContent fileContent, @GloopParameter(allowNull=false) long lastModifiedTime) throws org.apache.commons.vfs2.FileSystemException
Sets the last modified time of the given file if it it exists.- Parameters:
fileContent
- the file contentlastModifiedTime
- the new last modified time- Throws:
org.apache.commons.vfs2.FileSystemException
- if the file is read-only; is being written to; or on error setting the last-modified timestamp- Since:
- 1.0
-
readFile
public static void readFile(@GloopParameter(allowNull=false) org.apache.commons.vfs2.FileContent fileContent, @GloopParameter(allowNull=false) org.apache.commons.vfs2.FileContent targetContent) throws IOException
Reads the content from thefileContent
, writing it totargetContent
.- Parameters:
fileContent
- the source file contenttargetContent
- the destination file content- Throws:
IOException
- Since:
- 1.0
-
readFile
public static void readFile(@GloopParameter(allowNull=false) org.apache.commons.vfs2.FileContent fileContent, @GloopParameter(allowNull=false) org.apache.commons.vfs2.FileObject targetObject) throws IOException
Reads the content from thefileContent
, writing it totargetObject
.- Parameters:
fileContent
- the source file contenttargetObject
- the destination file- Throws:
IOException
- Since:
- 1.0
-
readFile
public static void readFile(@GloopParameter(allowNull=false) org.apache.commons.vfs2.FileContent fileContent, @GloopParameter(allowNull=false) OutputStream outputStream, @GloopParameter(allowNull=false,defaultValue="1024") int bufferSize) throws IOException
Reads the content from thefileContent
, writing it tooutputStream
.- Parameters:
fileContent
- the source file contentoutputStream
- destination output streambufferSize
- buffer size to write data in chunks- Throws:
IOException
- Since:
- 1.0
-
readFileAsString
public static String readFileAsString(@GloopParameter(allowNull=false) org.apache.commons.vfs2.FileContent fileContent, @GloopParameter(allowNull=false,defaultValue="1024") int bufferSize) throws IOException
Reads the content of the file, returning it as a string.- Parameters:
fileContent
- source file contentbufferSize
- buffer size to write data in chunks- Returns:
- content of provided file as a string
- Throws:
IOException
- Since:
- 1.0
-
readFileAsBytes
public static byte[] readFileAsBytes(@GloopParameter(allowNull=false) org.apache.commons.vfs2.FileContent fileContent, @GloopParameter(allowNull=false,defaultValue="1024") int bufferSize) throws IOException
Reads the content of the file, returning it as an array of bytes.- Parameters:
fileContent
- source file contentbufferSize
- buffer size to write data in chunks- Returns:
- content of provided file as an array of bytes
- Throws:
IOException
- Since:
- 1.0
-
writeFile
public static void writeFile(@GloopParameter(allowNull=false) org.apache.commons.vfs2.FileContent fileContent, @GloopParameter(allowNull=false) InputStream inputStream, @GloopParameter(defaultValue="false") boolean append, @GloopParameter(allowNull=false,defaultValue="1024") int bufferSize) throws IOException
Writes the content of the input stream to thefileContent
.- Parameters:
fileContent
- where the data will be writteninputStream
- contains the data to be writtenappend
- whether or not to append the data in the stream to the current file contentbufferSize
- the buffer size used when writinginputStream
tofileContent
- Throws:
IOException
- Since:
- 1.0
-
writeFile
public static void writeFile(@GloopParameter(allowNull=false) org.apache.commons.vfs2.FileContent fileContent, @GloopParameter(allowNull=false) InputStream inputStream, @GloopParameter(defaultValue="false") boolean append) throws IOException
Writes the content of the input stream to thefileContent
, with a buffer size of4096
.- Parameters:
fileContent
- where the data will be writteninputStream
- contains the data to be writtenappend
- whether or not to append the data in the stream to the current file content- Throws:
IOException
- Since:
- 1.1
-
writeFile
public static void writeFile(@GloopParameter(allowNull=false) org.apache.commons.vfs2.FileContent fileContent, @GloopParameter(allowNull=false) String data, @GloopParameter(defaultValue="false") boolean append, @GloopParameter(allowNull=false,defaultValue="1024") int bufferSize) throws IOException
Writes the content of the input string to the file.- Parameters:
fileContent
- where the data will be writtendata
- the data to be writtenappend
- whether or not to append the data in the stream to the current file content- Throws:
IOException
- Since:
- 1.0
-
writeFile
public static void writeFile(@GloopParameter(allowNull=false) org.apache.commons.vfs2.FileContent fileContent, @GloopParameter(allowNull=false) byte[] data, @GloopParameter(defaultValue="false") boolean append, @GloopParameter(allowNull=false,defaultValue="1024") int bufferSize) throws IOException
Writes an array of bytes to the file.- Parameters:
fileContent
- where the data will be writtendata
- the data to be writtenappend
- whether or not to append the data in the stream to the current file content- Throws:
IOException
- Since:
- 1.0
-
-