View Source AnkiConnect.Actions.Media (anki_connect v0.1.1)
Media actions.
All functions are delegated inside AnkiConnect
module, so you should import them from there.
Link to this section Summary
Functions
Deletes the specified file inside the media folder.
Gets the full path to the collection.media
folder of the currently opened profile.
Gets the names of media files matched the pattern. Returning all names by default.
Retrieves the base64-encoded contents of the specified file, returning error if the file does not exist.
Stores a file with the specified base64-encoded contents inside the media folder.
Link to this section Functions
Deletes the specified file inside the media folder.
sample-param
Sample param:
%{
filename: "_hello.txt"
}
sample-result
Sample result:
{:ok, nil}
Gets the full path to the collection.media
folder of the currently opened profile.
sample-result
Sample result:
{:ok, "/home/user/.local/share/Anki2/Main/collection.media"}
Gets the names of media files matched the pattern. Returning all names by default.
sample-param
Sample param:
%{
pattern: "_hell*.txt"
}
sample-result
Sample result:
{:ok, ["_hello.txt"]}
Retrieves the base64-encoded contents of the specified file, returning error if the file does not exist.
sample-param
Sample param:
%{
filename: "_hello.txt"
}
sample-result
Sample result:
{:ok, "SGVsbG8sIHdvcmxkIQ=="}
Stores a file with the specified base64-encoded contents inside the media folder.
Alternatively you can specify a absolute file path, or a url from where the file shell be downloaded. If more than one of data
, path
and url
are provided, the data
field will be used first, then path
, and finally url
.
To prevent Anki from removing files not used by any cards (e.g. for configuration files), prefix the filename with an underscore. These files are still synchronized to AnkiWeb.
Any existing file with the same name is deleted by default. Set deleteExisting to false to prevent that by letting Anki give the new file a non-conflicting name.
sample-param-base64-encoded
Sample param (base64 encoded):
%{
filename: "_hello.txt",
data: "SGVsbG8sIHdvcmxkIQ=="
}
sample-param-absolute-path
Sample param (absolute path):
%{
filename: "_hello.txt",
path: "/path/to/file"
}
sample-param-url
Sample param (URL):
%{
filename: "_hello.txt",
url: "https://url.to.file"
}
sample-result
Sample result:
{:ok, "_hello.txt"}