resx_dropbox v0.1.0 ResxDropbox
A producer to handle dropbox URIs.
ResxDropbox.open("dbpath:/path/to/file.txt")
ResxDropbox.open("dbid:AAAAAAAAAAAAAAAAAAAAAA")
Add ResxDropbox
to your list of resx producers.
config :resx,
producers: [ResxDropbox]
Types
MIME types are inferred from file extension names. Following the behaviour of Resx.Producers.File.mime/1
.
Authorities
Authorities are used to match with a dropbox access token. When no authority is provided, it will attempt to find an access token for nil
. These tokens can be configured by setting the :token
configuration option for :resx_dropbox
.
config :resx_dropbox,
token: "TOKEN"
config :resx_dropbox,
token: %{ nil => "TOKEN1", "foo@bar" => "TOKEN2", "main" => "TOKEN3" }
config :resx_dropbox,
token: { MyDropboxTokenRetriever, :to_token, 1 }
The :token
field should contain either a string which will be the token used by any authority, or a map of authority keys and token string values, or a callback function that will be passed the authority and should return { :ok, token }
or :error
if there is no token for the given authority. Valid function formats are any callback variant, see Callback
for more information.
Sources
Dropbox sources are dropbox content references with a backup data source, so if the content no longer exists it will revert back to getting the data from the source and creating the content again. The data source is any compatible URI.
ResxDropbox.open("dbpath:/foo.txt?source=ZGF0YTp0ZXh0L3BsYWluO2NoYXJzZXQ9VVMtQVNDSUk7YmFzZTY0LGRHVnpkQT09")
If the source cannot be accessed anymore but the content exists, it will access the content. If both cannot be accessed then the request will fail.
Link to this section Summary
Functions
See if two references are alike
Discard a dropbox resource
Opens a dropbox resource
Store a resource as a file in dropbox
Link to this section Functions
See if two references are alike.
This will check if two references are referring to the same content regardless of if they're not of the same kind (aren't both paths or ids) or have different access tokens (two different accounts referencing the same shared file). Due to this not all the comparisons can be made without making an API request, if there is ever a failure accessing that API then the function will assume that the two references are not alike.
discard(Resx.ref(), meta: boolean(), content: boolean()) :: :ok | Resx.error(Resx.resource_error() | Resx.reference_error())
Discard a dropbox resource.
The following options are all optional:
:meta
- specify whether the meta file should also be deleted. By default it is.:content
- specify whether the content file should also be deleted. By default it is.
Opens a dropbox resource.
The :timestamp
allows for choosing between :server
or :client
timestamps. By default the server timestamp is used, or whatever application timestamp setting was given.
config :resx_dropbox,
timestamp: :client
If it is a source reference then a :mute
option may be passed, which expects a boolean indicating whether the action should appear in the dropbox change history or not.
Store a resource as a file in dropbox.
The required options are:
:path
- expects a string denoting the path the file will be stored at.
The following options are all optional:
:auth
- expects the authority to lookup the token of.:mute
- expects a boolean indicating whether the action should appear in the dropbox change history or not.