Download all attachments in a folder/for an item #266
Closed
cboulanger
started this conversation in
Ideas
Replies: 2 comments
-
Havn't tried, but I think this might work: if (!item) return;
let attachments = [];
if (item.isAttachment()) {
attachments = [item];
} else if (item.isRegularItem()) {
attachments = Zotero.Items.get(item.getAttachments());
} else {
return;
}
for (let attachment of attachments) {
let path = await attachment.getFilePathAsync();
if (!path) {
let fileSyncingEnabled = Zotero.Sync.Storage.Local.getEnabledForLibrary(
item.libraryID
);
if (!fileSyncingEnabled) {
return "File sync is disabled";
}
try {
let results = await Zotero.Sync.Runner.downloadFile(attachment);
if (!results || !results.localChanges) {
return "Download failed";
}
} catch (e) {
Zotero.debug(e);
}
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks! I updated it a bit, works like a charm: #267 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Feature: I would like to have an action for collections that would download all attachments for all items in a collection.
Background: I try to save space on my laptop by downloading attachments on demand. However, sometimes it is necessary to have the attachments for a particular collection for situations where I have no internet connection.
Has someone tried that already? If not: a few pointers to the relevant API parts would help, then I can write it myself.
Beta Was this translation helpful? Give feedback.
All reactions