diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2022-03-13 21:17:41 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-13 21:17:41 -0400 |
commit | f98f5f939552d14b014396ce933bba4faa9607bb (patch) | |
tree | 0e90b172417301f15d99599d64ea7aa7e0336c72 /ext/js/comm/anki.js | |
parent | 1590f5218c5872f3683820e9611d4a4fa2b7c341 (diff) |
Improve Anki storeMediaFile (#2084)
* Use the return value of storeMediaFile
* Update documentation
Diffstat (limited to 'ext/js/comm/anki.js')
-rw-r--r-- | ext/js/comm/anki.js | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/ext/js/comm/anki.js b/ext/js/comm/anki.js index 54b12384..6921caf5 100644 --- a/ext/js/comm/anki.js +++ b/ext/js/comm/anki.js @@ -105,12 +105,19 @@ class AnkiConnect { return await this.guiBrowse(`nid:${noteId}`); } - async storeMediaFile(fileName, dataBase64) { + /** + * Stores a file with the specified base64-encoded content inside Anki's media folder. + * @param {string} fileName The name of the file. + * @param {string} content The base64-encoded content of the file. + * @returns {?string} The actual file name used to store the file, which may be different; or `null` if the file was not stored. + * @throws {Error} An error is thrown is this object is not enabled. + */ + async storeMediaFile(fileName, content) { if (!this._enabled) { throw new Error('AnkiConnect not enabled'); } await this._checkVersion(); - return await this._invoke('storeMediaFile', {filename: fileName, data: dataBase64}); + return await this._invoke('storeMediaFile', {filename: fileName, data: content}); } async findNoteIds(notes) { |