ExFTP.Storage.S3Connector (ExFTP v1.2.0)
View SourceWhen storage_connector is ExFTP.Storage.S3Connector, this connector will use any S3-compatible storage provider.
Underneath the hood, ex_ftp is using ExAws.S3, so you'll need that configured properly.
โ๏ธ Configuration
Keys
- storage_connector ==
ExFTP.Storage.FileConnector - storage_config ::
ExFTP.Storage.S3ConnectorConfig.t/0
Example
%{
# ... ,
storage_connector: ExFTP.Storage.S3Connector,
storage_config: %{
# the `/` path of the FTP server will point to s3://{my-storage-bucket}/
storage_bucket: "my-storage-bucket"
}
}๐ See Also
๐ Resources
Summary
Functions
Create a function/1 that writes a stream to storage
Deletes a given directory
Deletes a given file
Whether a given path is an existing directory
Returns a stream to read the raw bytes of an object specified by a given path
Returns a ExFTP.StorageConnector.content_info/0 representing a given path
Returns a list of ExFTP.StorageConnector.content_info/0 representing each object in a given directory
Returns the current working directory
Creates a directory, given a path
Functions
@spec create_write_func( path :: ExFTP.StorageConnector.path(), connector_state :: ExFTP.StorageConnector.connector_state(), opts :: list() ) :: function()
Create a function/1 that writes a stream to storage
๐ท๏ธ Params
- path ::
t:path/0 - connector_state ::
t:connector_state/0 - opts :: list of options
@spec delete_directory( path :: ExFTP.StorageConnector.path(), connector_state :: ExFTP.StorageConnector.connector_state() ) :: {:ok, ExFTP.StorageConnector.connector_state()} | {:error, term()}
Deletes a given directory
๐ท๏ธ Params
- path ::
ExFTP.StorageConnector.path/0 - connector_state ::
ExFTP.StorageConnector.connector_state/0
โคต๏ธ Returns
โ On Success
{:ok, connector_state}โ On Failure
{:error, err}๐ป Examples
iex> alias ExFTP.Storage.S3Connector
iex> connector_state = %{current_working_directory: "/"}
iex> dir_to_make = "/new_dir"
iex> {:ok, connector_state} = S3Connector.make_directory(dir_to_make, connector_state)
iex> dir_to_rm = dir_to_make
iex> {:ok, connector_state} = S3Connector.delete_directory(dir_to_rm, connector_state)
iex> S3Connector.directory_exists?(dir_to_rm, connector_state)
false๐ See Also
๐ Resources
- ๐ RFC 959 (page-32)
- ๐ RFC 3659
- ๐ฌ Contact the maintainer (he's happy to help!)
@spec delete_file( path :: ExFTP.StorageConnector.path(), connector_state :: ExFTP.StorageConnector.connector_state() ) :: {:ok, ExFTP.StorageConnector.connector_state()} | {:error, term()}
Deletes a given file
๐ท๏ธ Params
- path ::
ExFTP.StorageConnector.path/0 - connector_state ::
ExFTP.StorageConnector.connector_state/0
โคต๏ธ Returns
โ On Success
{:ok, connector_state}โ On Failure
{:error, err}๐ See Also
๐ Resources
- ๐ RFC 959 (page-32)
- ๐ RFC 3659
- ๐ฌ Contact the maintainer (he's happy to help!)
@spec directory_exists?( path :: ExFTP.StorageConnector.path(), connector_state :: ExFTP.StorageConnector.connector_state() ) :: boolean()
Whether a given path is an existing directory
๐ท๏ธ Params
- path ::
ExFTP.StorageConnector.path/0 - connector_state ::
ExFTP.StorageConnector.connector_state/0
โคต๏ธ Returns
โ On Success
`true` or `false`๐ป Examples
iex> alias ExFTP.Storage.S3Connector
iex> S3Connector.directory_exists?("/", %{current_working_directory: "/"})
true
iex> S3Connector.directory_exists?("/does-not-exist", %{current_working_directory: "/"})
false๐ See Also
๐ Resources
- ๐ RFC 959 (page-32)
- ๐ RFC 3659
- ๐ฌ Contact the maintainer (he's happy to help!)
@spec get_content( path :: ExFTP.StorageConnector.path(), connector_state :: ExFTP.StorageConnector.connector_state() ) :: {:ok, any()} | {:error, term()}
Returns a stream to read the raw bytes of an object specified by a given path
๐ท๏ธ Params
- path ::
ExFTP.StorageConnector.path/0 - connector_state ::
ExFTP.StorageConnector.connector_state/0
โคต๏ธ Returns
โ On Success
{:ok, data}โ On Failure
{:error, err}๐ See Also
๐ Resources
- ๐ RFC 959 (page-30)
- ๐ RFC 3659
- ๐ฌ Contact the maintainer (he's happy to help!)
@spec get_content_info( path :: ExFTP.StorageConnector.path(), connector_state :: ExFTP.StorageConnector.connector_state() ) :: {:ok, ExFTP.StorageConnector.content_info()} | {:error, term()}
Returns a ExFTP.StorageConnector.content_info/0 representing a given path
๐ท๏ธ Params
- path ::
ExFTP.StorageConnector.path/0 - connector_state ::
ExFTP.StorageConnector.connector_state/0
โคต๏ธ Returns
โ On Success
{:ok, %{...}}โ On Failure
{:error, err}๐ See Also
ExFTP.StorageConnector.content_info/0ExFTP.StorageConnector.get_content_info/2get_directory_contents/2
๐ Resources
- ๐ RFC 959 (page-32)
- ๐ RFC 3659
- ๐ฌ Contact the maintainer (he's happy to help!)
@spec get_directory_contents( path :: ExFTP.StorageConnector.path(), connector_state :: ExFTP.StorageConnector.connector_state() ) :: {:ok, [ExFTP.StorageConnector.content_info()]} | {:error, term()}
Returns a list of ExFTP.StorageConnector.content_info/0 representing each object in a given directory
๐ท๏ธ Params
- path ::
ExFTP.StorageConnector.path/0 - connector_state ::
ExFTP.StorageConnector.connector_state/0
โคต๏ธ Returns
โ On Success
{:ok, [%{...}, ...]}โ On Failure
{:error, err}๐ป Examples
iex> alias ExFTP.Storage.S3Connector
iex> connector_state = %{current_working_directory: "/"}
iex> dir = "/"
iex> {:ok, _content_infos} = S3Connector.get_directory_contents(dir, connector_state)๐ See Also
๐ Resources
- ๐ RFC 959 (page-32)
- ๐ RFC 3659
- ๐ฌ Contact the maintainer (he's happy to help!)
@spec get_working_directory( connector_state :: ExFTP.StorageConnector.connector_state() ) :: String.t()
Returns the current working directory
๐ท๏ธ Params
- connector_state ::
ExFTP.StorageConnector.connector_state/0
๐ป Examples
iex> alias ExFTP.Storage.S3Connector
iex> S3Connector.get_working_directory(%{current_working_directory: "/"})
"/"๐ See Also
๐ Resources
- ๐ RFC 959 (page-32)
- ๐ RFC 3659
- ๐ฌ Contact the maintainer (he's happy to help!)
@spec make_directory( path :: ExFTP.StorageConnector.path(), connector_state :: ExFTP.StorageConnector.connector_state() ) :: {:ok, ExFTP.StorageConnector.connector_state()} | {:error, term()}
Creates a directory, given a path
๐ท๏ธ Params
- path ::
ExFTP.StorageConnector.path/0 - connector_state ::
ExFTP.StorageConnector.connector_state/0
โคต๏ธ Returns
โ On Success
{:ok, connector_state}โ On Failure
{:error, err}๐ป Examples
iex> alias ExFTP.Storage.S3Connector
iex> connector_state = %{current_working_directory: "/"}
iex> dir_to_make = "/new_dir/"
iex> {:ok, connector_state} = S3Connector.make_directory(dir_to_make, connector_state)
iex> S3Connector.directory_exists?(dir_to_make, connector_state)
true๐ See Also
๐ Resources
- ๐ RFC 959 (page-32)
- ๐ RFC 3659
- ๐ฌ Contact the maintainer (he's happy to help!)