ReferenceError: OS is not defined
Hi, our company recently updated Zotero (from a rather old version) to version 7.0.24. I now have an issue with a Javascript that we use to copy the attachment to our local storage.
The critical code is this one:
await OS.File.Copy(attachmentPath, databasePath);
It fives the error: "ReferenceError: OS is not defined"
Any suggestions? Is the use of OS deprecated? I cannot find this in the documentation.
Regards,
Alex
This is the full code:
var selectedItems = ZoteroPane.getSelectedItems();
var item = selectedItems[0];
var baseurl = "file:\\\\I:\\WorkingGroups\\MPS\\KnowledgeBase\\Zotero\\published_in_database\\"
var basepath = "I:\\WorkingGroups\\MPS\\KnowledgeBase\\Zotero\\published_in_database\\"
if (item && !item.isNote()) {
if (item.isAttachment()) {
alert('The attachment is selected, please select the parent item')
}
if (item.isRegularItem()) {
let attachmentIDs = item.getAttachments();
await ZoteroPane.selectItem(attachmentIDs[0]);
await ZoteroPane.renameSelectedAttachmentsFromParents();
let attachment = Zotero.Items.get(attachmentIDs[0]);
item.setField('url',baseurl + attachment.getField('title'));
await item.saveTx();
databasePath = basepath + attachment.getField('title');
attachmentPath = attachment.getFilePath();
await OS.File.Copy(attachmentPath, databasePath);
activeitem = item.getField('title');
alert('Database URL added to parent item \('+activeitem+'\), renamed attached file and copied file to MPS database. Now move the parent item to the MPS library and move your local version of the parent item to the trash.')
}
}
The critical code is this one:
await OS.File.Copy(attachmentPath, databasePath);
It fives the error: "ReferenceError: OS is not defined"
Any suggestions? Is the use of OS deprecated? I cannot find this in the documentation.
Regards,
Alex
This is the full code:
var selectedItems = ZoteroPane.getSelectedItems();
var item = selectedItems[0];
var baseurl = "file:\\\\I:\\WorkingGroups\\MPS\\KnowledgeBase\\Zotero\\published_in_database\\"
var basepath = "I:\\WorkingGroups\\MPS\\KnowledgeBase\\Zotero\\published_in_database\\"
if (item && !item.isNote()) {
if (item.isAttachment()) {
alert('The attachment is selected, please select the parent item')
}
if (item.isRegularItem()) {
let attachmentIDs = item.getAttachments();
await ZoteroPane.selectItem(attachmentIDs[0]);
await ZoteroPane.renameSelectedAttachmentsFromParents();
let attachment = Zotero.Items.get(attachmentIDs[0]);
item.setField('url',baseurl + attachment.getField('title'));
await item.saveTx();
databasePath = basepath + attachment.getField('title');
attachmentPath = attachment.getFilePath();
await OS.File.Copy(attachmentPath, databasePath);
activeitem = item.getField('title');
alert('Database URL added to parent item \('+activeitem+'\), renamed attached file and copied file to MPS database. Now move the parent item to the MPS library and move your local version of the parent item to the trash.')
}
}
Upgrade Storage
Not sure why that'd have worked previously for you -- that hasn't changed
(Please post development questions to zotero-dev rather than the forums.)