Class FileEndpoint

  • All Implemented Interfaces:
    AutoCloseable, org.apache.camel.CamelContextAware, org.apache.camel.Endpoint, org.apache.camel.IsSingleton, org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.spi.BrowsableEndpoint, org.apache.camel.spi.HasId, org.apache.camel.StatefulService, org.apache.camel.SuspendableService

    @UriEndpoint(firstVersion="1.0.0",
                 scheme="file",
                 title="File",
                 syntax="file:directoryName",
                 category={FILE,CORE})
    public class FileEndpoint
    extends GenericFileEndpoint<File>
    Read and write files.
    • Constructor Detail

      • FileEndpoint

        public FileEndpoint()
      • FileEndpoint

        public FileEndpoint​(String endpointUri,
                            org.apache.camel.Component component)
    • Method Detail

      • createPollingConsumer

        public org.apache.camel.PollingConsumer createPollingConsumer()
                                                               throws Exception
        Specified by:
        createPollingConsumer in interface org.apache.camel.Endpoint
        Overrides:
        createPollingConsumer in class org.apache.camel.support.DefaultEndpoint
        Throws:
        Exception
      • newFileConsumer

        protected FileConsumer newFileConsumer​(org.apache.camel.Processor processor,
                                               GenericFileOperations<File> operations)
        Strategy to create a new FileConsumer
        Parameters:
        processor - the given processor
        operations - file operations
        Returns:
        the created consumer
      • getFile

        public File getFile()
      • setFile

        public void setFile​(File file)
        The starting directory
      • createEndpointUri

        protected String createEndpointUri()
        Overrides:
        createEndpointUri in class org.apache.camel.support.DefaultEndpoint
      • isCopyAndDeleteOnRenameFail

        public boolean isCopyAndDeleteOnRenameFail()
      • setCopyAndDeleteOnRenameFail

        public void setCopyAndDeleteOnRenameFail​(boolean copyAndDeleteOnRenameFail)
        Whether to fallback and do a copy and delete file, in case the file could not be renamed directly. This option is not available for the FTP component.
      • isRenameUsingCopy

        public boolean isRenameUsingCopy()
      • setRenameUsingCopy

        public void setRenameUsingCopy​(boolean renameUsingCopy)
        Perform rename operations using a copy and delete strategy. This is primarily used in environments where the regular rename operation is unreliable (e.g. across different file systems or networks). This option takes precedence over the copyAndDeleteOnRenameFail parameter that will automatically fall back to the copy and delete strategy, but only after additional delays.
      • isStartingDirectoryMustExist

        public boolean isStartingDirectoryMustExist()
      • setStartingDirectoryMustExist

        public void setStartingDirectoryMustExist​(boolean startingDirectoryMustExist)
        Whether the starting directory must exist. Mind that the autoCreate option is default enabled, which means the starting directory is normally auto created if it doesn't exist. You can disable autoCreate and enable this to ensure the starting directory must exist. Will thrown an exception if the directory doesn't exist.
      • isStartingDirectoryMustHaveAccess

        public boolean isStartingDirectoryMustHaveAccess()
      • setStartingDirectoryMustHaveAccess

        public void setStartingDirectoryMustHaveAccess​(boolean startingDirectoryMustHaveAccess)
        Whether the starting directory has access permissions. Mind that the startingDirectoryMustExist parameter must be set to true in order to verify that the directory exists. Will thrown an exception if the directory doesn't have read and write permissions.
      • isDirectoryMustExist

        public boolean isDirectoryMustExist()
      • setDirectoryMustExist

        public void setDirectoryMustExist​(boolean directoryMustExist)
        Similar to the startingDirectoryMustExist option but this applies during polling (after starting the consumer).
      • isForceWrites

        public boolean isForceWrites()
      • setForceWrites

        public void setForceWrites​(boolean forceWrites)
        Whether to force syncing writes to the file system. You can turn this off if you do not want this level of guarantee, for example if writing to logs / audit logs etc; this would yield better performance.
      • isProbeContentType

        public boolean isProbeContentType()
      • setProbeContentType

        public void setProbeContentType​(boolean probeContentType)
        Whether to enable probing of the content type. If enable then the consumer uses Files.probeContentType(java.nio.file.Path) to determine the content-type of the file, and store that as a header with key Exchange.FILE_CONTENT_TYPE on the Message.
      • getExtendedAttributes

        public String getExtendedAttributes()
      • setExtendedAttributes

        public void setExtendedAttributes​(String extendedAttributes)
        To define which file attributes of interest. Like posix:permissions,posix:owner,basic:lastAccessTime, it supports basic wildcard like posix:*, basic:lastAccessTime
      • setResumeStrategy

        public void setResumeStrategy​(FileConsumerResumeStrategy resumeStrategy)
        Set a resume strategy for files. This makes it possible to define a strategy for resuming reading files after the last point before stopping the application. See the FileConsumerResumeStrategy for implementation details
        Parameters:
        resumeStrategy - an instance of the resume strategy to be used
      • chmodPermissionsAreValid

        public boolean chmodPermissionsAreValid​(String chmod)
        Chmod value must be between 000 and 777; If there is a leading digit like in 0755 we will ignore it.
      • getChmod

        public String getChmod()
      • setChmod

        public void setChmod​(String chmod)
        Specify the file permissions which is sent by the producer, the chmod value must be between 000 and 777; If there is a leading digit like in 0755 we will ignore it.
      • getChmodDirectory

        public String getChmodDirectory()
      • setChmodDirectory

        public void setChmodDirectory​(String chmodDirectory)
        Specify the directory permissions used when the producer creates missing directories, the chmod value must be between 000 and 777; If there is a leading digit like in 0755 we will ignore it.