public final class FtpOperations
extends org.mule.extension.file.common.api.BaseFileSystemOperations
| Constructor and Description |
|---|
FtpOperations() |
| Modifier and Type | Method and Description |
|---|---|
void |
copy(org.mule.extension.file.common.api.FileConnectorConfig config,
org.mule.extension.file.common.api.FileSystem fileSystem,
String sourcePath,
String targetPath,
boolean createParentDirectories,
boolean overwrite,
String renameTo)
Copies the file at the
sourcePath into the targetPath. |
void |
createDirectory(org.mule.extension.file.common.api.FileSystem fileSystem,
String directoryPath)
Creates a new directory on
directoryPath |
void |
delete(org.mule.extension.file.common.api.FileSystem fileSystem,
String path)
Deletes the file pointed by
path, provided that it's not locked |
List<org.mule.runtime.extension.api.runtime.operation.Result<InputStream,FtpFileAttributes>> |
list(org.mule.extension.file.common.api.FileConnectorConfig config,
FtpFileSystem fileSystem,
String directoryPath,
boolean recursive,
FtpFileMatcher matcher)
Lists all the files in the
directoryPath which match the given matcher. |
void |
move(org.mule.extension.file.common.api.FileConnectorConfig config,
org.mule.extension.file.common.api.FileSystem fileSystem,
String sourcePath,
String targetPath,
boolean createParentDirectories,
boolean overwrite,
String renameTo)
Moves the file at the
sourcePath into the targetPath. |
org.mule.runtime.extension.api.runtime.operation.Result<InputStream,FtpFileAttributes> |
read(org.mule.extension.file.common.api.FileConnectorConfig config,
FtpFileSystem fileSystem,
String path,
boolean lock)
Obtains the content and metadata of a file at a given path.
|
void |
rename(org.mule.extension.file.common.api.FileSystem fileSystem,
String path,
String to,
boolean overwrite)
Renames the file pointed by
path to the name provided on the to parameter |
void |
write(org.mule.extension.file.common.api.FileConnectorConfig config,
org.mule.extension.file.common.api.FileSystem fileSystem,
String path,
InputStream content,
String encoding,
boolean createParentDirectories,
boolean lock,
org.mule.extension.file.common.api.FileWriteMode mode)
Writes the
content into the file pointed by path. |
@Summary(value="List all the files from given directory") @Throws(value=org.mule.extension.file.common.api.exceptions.FileListErrorTypeProvider.class) public List<org.mule.runtime.extension.api.runtime.operation.Result<InputStream,FtpFileAttributes>> list(@Config org.mule.extension.file.common.api.FileConnectorConfig config, @Connection FtpFileSystem fileSystem, @Path(type=DIRECTORY,location=EXTERNAL) String directoryPath, @Optional(defaultValue="false") boolean recursive, @Optional @DisplayName(value="File Matching Rules") @Summary(value="Matcher to filter the listed files") FtpFileMatcher matcher)
directoryPath which match the given matcher.
If the listing encounters a directory, the output list will include its contents depending on the value of the
recursive parameter.
If recursive is set to true but a found directory is rejected by the matcher, then there won't be any
recursion into such directory.
config - the config that is parameterizing this operationdirectoryPath - the path to the directory to be listedrecursive - whether to include the contents of sub-directories. Defaults to false.matcher - a matcher used to filter the output listList of messages each one containing each file's content in the payload and metadata in the
attributesIllegalArgumentException - if directoryPath points to a file which doesn't exist or is not a directory@Summary(value="Obtains the content and metadata of a file at a given path")
@Throws(value=org.mule.extension.file.common.api.exceptions.FileReadErrorTypeProvider.class)
@MediaType(value="*/*",
strict=false)
public org.mule.runtime.extension.api.runtime.operation.Result<InputStream,FtpFileAttributes> read(@Config
org.mule.extension.file.common.api.FileConnectorConfig config,
@Connection
FtpFileSystem fileSystem,
@DisplayName(value="File Path") @Path(type=FILE,location=EXTERNAL)
String path,
@Optional(defaultValue="false") @Placement(tab="Advanced")
boolean lock)
Message which payload is a
InputStream with the file's content, and the metadata is represent as a FtpFileAttributes object that's
placed as the message attributes.
If the lock parameter is set to true, then a file system level lock will be placed on the file until the
input stream this operation returns is closed or fully consumed. Because the lock is actually provided by the host file
system, its behavior might change depending on the mounted drive and the operation system on which mule is running. Take that
into consideration before blindly relying on this lock.
This method also makes a best effort to determine the mime type of the file being read. The file's extension will
be used to make an educated guess on the file's mime type. The user also has the chance to force the output encoding and
mimeType through the outputEncoding and outputMimeType optional parameters.
config - the config that is parameterizing this operationfileSystem - a reference to the host FileSystempath - the path to the file to be readlock - whether or not to lock the file. Defaults to false.FileAttributes instanceIllegalArgumentException - if the file at the given path doesn't exist@Summary(value="Writes the given \"Content\" in the file pointed by \"Path\"")
@Throws(value=org.mule.extension.file.common.api.exceptions.FileWriteErrorTypeProvider.class)
public void write(@Config
org.mule.extension.file.common.api.FileConnectorConfig config,
@Connection
org.mule.extension.file.common.api.FileSystem fileSystem,
@Path(type=FILE,location=EXTERNAL)
String path,
@Content @Summary(value="Content to be written into the file")
InputStream content,
@Optional @Summary(value="Encoding when trying to write a String file. If not set, defaults to the configuration one or the Mule default")
String encoding,
@Optional(defaultValue="true")
boolean createParentDirectories,
@Optional(defaultValue="false")
boolean lock,
@Optional(defaultValue="OVERWRITE") @Summary(value="How the file is going to be written") @DisplayName(value="Write Mode")
org.mule.extension.file.common.api.FileWriteMode mode)
content into the file pointed by path.
If the directory on which the file is attempting to be written doesn't exist, then the operation will either throw
FTP:ILLEGAL_PATH error or create such folder depending on the value of the createParentDirectory.
If the file itself already exists, then the behavior depends on the supplied mode.
This operation also supports locking support depending on the value of the lock argument, but following the same
rules and considerations as described in the read operation.
config - the FileConnectorConfig on which the operation is being executedfileSystem - a reference to the host FileSystempath - the path of the file to be writtencontent - the content to be written into the file. Defaults to the current Message payloadencoding - when content is a String, this attribute specifies the encoding to be used when writing. If
not set, then it defaults to FileConnectorConfig.getDefaultWriteEncoding()createParentDirectories - whether or not to attempt creating any parent directories which don't exists.lock - whether or not to lock the file. Defaults to falsemode - a FileWriteMode. Defaults to OVERWRITEIllegalArgumentException - if an illegal combination of arguments is supplied@Summary(value="Copies a file")
@Throws(value=org.mule.extension.file.common.api.exceptions.FileCopyErrorTypeProvider.class)
public void copy(@Config
org.mule.extension.file.common.api.FileConnectorConfig config,
@Connection
org.mule.extension.file.common.api.FileSystem fileSystem,
@Path(location=EXTERNAL)
String sourcePath,
@Path(type=DIRECTORY,location=EXTERNAL)
String targetPath,
@Optional(defaultValue="true")
boolean createParentDirectories,
@Optional(defaultValue="false")
boolean overwrite,
@Optional
String renameTo)
sourcePath into the targetPath.
If targetPath doesn't exist, and neither does its parent, then an attempt will be made to create depending on the
value of the createParentFolder argument. If such argument is , then a FTP:ILLEGAL_PATH will
be thrown.
If the target file already exists, then it will be overwritten if the overwrite argument is true. Otherwise,
FTP:FILE_ALREADY_EXISTS error will be thrown.
As for the sourcePath, it can either be a file or a directory. If it points to a directory, then it will be copied
recursively.
config - the config that is parameterizing this operationfileSystem - a reference to the host FileSystemsourcePath - the path to the file to be copiedtargetPath - the target directory where the file is going to be copiedcreateParentDirectories - whether or not to attempt creating any parent directories which don't exists.overwrite - whether or not overwrite the file if the target destination already exists.renameTo - copied file's new name. If not provided, original file name will be kept.IllegalArgumentException - if an illegal combination of arguments is supplied@Summary(value="Moves a file")
@Throws(value=org.mule.extension.file.common.api.exceptions.FileCopyErrorTypeProvider.class)
public void move(@Config
org.mule.extension.file.common.api.FileConnectorConfig config,
@Connection
org.mule.extension.file.common.api.FileSystem fileSystem,
@Path(location=EXTERNAL)
String sourcePath,
@Path(type=DIRECTORY,location=EXTERNAL)
String targetPath,
@Optional(defaultValue="true")
boolean createParentDirectories,
@Optional(defaultValue="false")
boolean overwrite,
@Optional
String renameTo)
sourcePath into the targetPath.
t, and neither does its parent, then an attempt will be made to create depending on the
value of the createParentFolder argument. If such argument is , then a FTP:ILLEGAL_PATH will
be thrown.
If the target file already exists, then it will be overwritten if the overwrite argument is true. Otherwise,
FTP:FILE_ALREADY_EXISTS error will be thrown.
As for the sourcePath, it can either be a file or a directory. If it points to a directory, then it will be moved
recursively.
config - the config that is parameterizing this operationfileSystem - a reference to the host FileSystemsourcePath - the path to the file to be copiedtargetPath - the target directorycreateParentDirectories - whether or not to attempt creating any parent directories which don't exists.overwrite - whether or not overwrite the file if the target destination already exists.renameTo - moved file's new name. If not provided, original file name will be kept.IllegalArgumentException - if an illegal combination of arguments is supplied@Summary(value="Deletes a file")
@Throws(value=org.mule.extension.file.common.api.exceptions.FileDeleteErrorTypeProvider.class)
public void delete(@Connection
org.mule.extension.file.common.api.FileSystem fileSystem,
@Path(location=EXTERNAL)
String path)
path, provided that it's not lockedfileSystem - a reference to the host FileSystempath - the path to the file to be deletedIllegalArgumentException - if filePath doesn't exist or is locked@Summary(value="Renames a file")
@Throws(value=org.mule.extension.file.common.api.exceptions.FileRenameErrorTypeProvider.class)
public void rename(@Connection
org.mule.extension.file.common.api.FileSystem fileSystem,
@Path(location=EXTERNAL)
String path,
@DisplayName(value="New Name")
String to,
@Optional(defaultValue="false")
boolean overwrite)
path to the name provided on the to parameter
to argument should not contain any path separator. FTP:ILLEGAL_PATH will be thrown if this
precondition is not honored.
fileSystem - a reference to the host FileSystempath - the path to the file to be renamedto - the file's new nameoverwrite - whether or not overwrite the file if the target destination already exists.@Summary(value="Creates a new directory")
@Throws(value=org.mule.extension.file.common.api.exceptions.FileRenameErrorTypeProvider.class)
public void createDirectory(@Connection
org.mule.extension.file.common.api.FileSystem fileSystem,
@Path(type=DIRECTORY,location=EXTERNAL)
String directoryPath)
directoryPathfileSystem - a reference to the host FileSystemdirectoryPath - the new directory's nameCopyright © 2018 MuleSoft, Inc.. All rights reserved.