View Source webdavfilez (webdavfilez v2.0.0)

WebDAV file storage. Can put, get and stream files. Uses a job queue which is regulated by "jobs".

Summary

Functions

Create a directory (bucket) at the URL.

Create a directory (bucket) at the URL, ignore acl options.

Delete the file at the url.

Fetch the data at the url.

Put a binary or file to the given url.

Put a binary or file to the given url. Set options for acl and/or content_type.

Async delete a file on WebDAV

Async delete a file on WebDAV, call ready_fun when ready.

Queue a named file deletion process, call ready_fun when ready.

Queue a file dowloader and call ready_fun when finished.

Queue a named file dowloader and call ready_fun when finished. Names must be unique, duplicates are refused with <tt>{error, {already_started, _}}</tt>.

Queue a file uploader. The data can be a binary or a filename.

Queue a file uploader and call ready_fun when finished.

Queue a file uploader and call ready_fun when finished. Options include the <tt>acl</tt> setting and <tt>content_type</tt> for the file.

Start a named file uploader. Names must be unique, duplicates are refused with <tt>{error, {already_started, _}}</tt>.

Queue a file downloader that will stream chunks to the given stream_fun. The default block size for the chunks is 64KB.

Queue a named file downloader that will stream chunks to the given stream_fun. The default block size for the chunks is 64KB.

Types

acl_type/0

-type acl_type() ::
          private | public_read | public_read_write | authenticated_read | bucket_owner_read |
          bucket_owner_full_control.

config/0

-type config() ::
          #{username := binary() | string(), password := binary() | string(), tls_options => list()}.

http_code/0

-type http_code() :: 100..600.

put_data/0

-type put_data() ::
          {data, binary()} |
          {filename, non_neg_integer(), file:filename_all()} |
          {filename, file:filename_all()}.

put_opt/0

-type put_opt() :: {acl, acl_type()} | {content_type, string()}.

put_opts/0

-type put_opts() :: [put_opt()].

queue_reply/0

-type queue_reply() :: {ok, any(), pid()} | {error, {already_started, pid()}}.

ready_fun/0

-type ready_fun() :: undefined | {atom(), atom(), list()} | fun() | pid().

stream_fun/0

-type stream_fun() :: {atom(), atom(), list()} | fun() | pid().

sync_reply/0

-type sync_reply() :: ok | {error, enoent | forbidden | http_code()}.

url/0

-type url() :: binary() | string().

Functions

create_bucket(Config, Url)

-spec create_bucket(config(), url()) -> sync_reply().

Create a directory (bucket) at the URL.

create_bucket(Config, Url, Opts)

-spec create_bucket(config(), url(), put_opts()) -> sync_reply().

Create a directory (bucket) at the URL, ignore acl options.

delete(Config, Url)

-spec delete(config(), url()) -> sync_reply().

Delete the file at the url.

get(Config, Url)

-spec get(config(), url()) ->
             {ok, ContentType :: binary(), Data :: binary()} | {error, enoent | forbidden | http_code()}.

Fetch the data at the url.

put(Config, Url, Payload)

-spec put(config(), url(), put_data()) -> sync_reply().

Put a binary or file to the given url.

put(Config, Url0, _, Opts)

-spec put(config(), url(), put_data(), put_opts()) -> sync_reply().

Put a binary or file to the given url. Set options for acl and/or content_type.

put_body_file(_)

queue_delete(Config, Url)

-spec queue_delete(config(), url()) -> queue_reply().

Async delete a file on WebDAV

queue_delete(Config, Url, ReadyFun)

-spec queue_delete(config(), url(), ready_fun()) -> queue_reply().

Async delete a file on WebDAV, call ready_fun when ready.

queue_delete_id(JobId, Config, Url, ReadyFun)

-spec queue_delete_id(any(), config(), url(), ready_fun()) -> queue_reply().

Queue a named file deletion process, call ready_fun when ready.

queue_get(Config, Url, ReadyFun)

-spec queue_get(config(), url(), ready_fun()) -> queue_reply().

Queue a file dowloader and call ready_fun when finished.

queue_get_id(JobId, Config, Url, ReadyFun)

-spec queue_get_id(any(), config(), url(), ready_fun()) -> queue_reply().

Queue a named file dowloader and call ready_fun when finished. Names must be unique, duplicates are refused with <tt>{error, {already_started, _}}</tt>.

queue_put(Config, Url, What)

-spec queue_put(config(), url(), put_data()) -> queue_reply().

Queue a file uploader. The data can be a binary or a filename.

queue_put(Config, Url, What, ReadyFun)

-spec queue_put(config(), url(), put_data(), ready_fun()) -> queue_reply().

Queue a file uploader and call ready_fun when finished.

queue_put(Config, Url, What, ReadyFun, Opts)

-spec queue_put(config(), url(), put_data(), ready_fun(), put_opts()) -> queue_reply().

Queue a file uploader and call ready_fun when finished. Options include the <tt>acl</tt> setting and <tt>content_type</tt> for the file.

queue_put_id(JobId, Config, Url, What, ReadyFun)

-spec queue_put_id(any(), config(), url(), put_data(), ready_fun()) -> queue_reply().

Start a named file uploader. Names must be unique, duplicates are refused with <tt>{error, {already_started, _}}</tt>.

queue_stream(Config, Url, StreamFun)

-spec queue_stream(config(), url(), stream_fun()) -> queue_reply().

Queue a file downloader that will stream chunks to the given stream_fun. The default block size for the chunks is 64KB.

queue_stream_id(JobId, Config, Url, StreamFun)

-spec queue_stream_id(any(), config(), url(), stream_fun()) -> queue_reply().

Queue a named file downloader that will stream chunks to the given stream_fun. The default block size for the chunks is 64KB.

stream(Config, Url, Fun)

-spec stream(config(), url(), stream_fun()) -> sync_reply().