Comments (7)
pdf name is the name you want the attachment to have in Zotero, like "my_pdf_10" and path must be the full file path: /foo/bar/baz.pdf
In order to upload to a specific collection, you have to either attach to an existing item in that collection, or create an item in the collection and attach to that.
from pyzotero.
Is this the right syntax?
pdf_path = Path('~/mypdf.pdf').expanduser()
assert pdf_path.exists()
print(zot.attachment_both([('mypdf', str(pdf_path))]))
This way the file appears in zotero, but the attachment is not found.
from pyzotero.
I'm not sure what you mean by "file appears in Zotero, but the attachment is not found". The file is the attachment, and if you don't specify a parent ID, it will appear as a standalone file.
What happens when you double-click it?
What happens if you use attachment_simple(['/path/to/filename.pdf'])
?
What happens if you use attachment_simple(['/path/to/filename.pdf'], parentid)
?
from pyzotero.
When I double click it in the Zotero GUI under "My Library/Unfiled Items", I get the error message "File Not Found The attached file could not be found at the following path: /path/to/zotero/storage/ID/mypdf.pdf"
The same happens with attachment_simple(['/path/to/filename.pdf'])
.
I'm not sure how to use the parentid
parameter. Is this the id of an item that already exists in the zotero database? If so, how can I find its id?
I have tried to upload another pdf with attachment_simple
, but got the error:
pyzotero.zotero_errors.RequestEntityTooLarge:
Code: 413
URL: https://api.zotero.org/users/myid/items/id/file
Method: POST
Response: File would exceed quota (300.1 > 300)
Which is strange since the file is only 113 KB big, and I can upload it to zotero via the GUI.
Also, strangely the file still appears in the zotero GUI with an existing attachment, but the attachment is stored under the original path instead of the zotero storage under /path/to/zotero/storage/
after executing the command that results in the error.
from pyzotero.
The parent ID is the id of an existing item. You can retrieve items in a number of ways (see docs). "id" is a field in the returned dict(s).
Your entity too large error may be related to the total size of your Zotero library. If your storage quota is already full or nearly full, you won't be able to upload additional items.
I can't reproduce the original errors – both attachment methods are working for me both with and without parent IDs using the latest Pyzotero version on macOS.
from pyzotero.
Thanks for the info, I was able to add the attachment to an existing item with the id/key.
You were right, after emptying the bin, the RequestEntityTooLarge
error disappeared.
In the dict returned by attachment_simple
in the field unchanged[0]["filename"]
I have the original file path, is that normal? Should it not be the zotero storage path /path/to/Zotero/storage
?
My output looks like this:
{
"success": [],
"failure": [],
"unchanged": [
{
"itemType": "attachment",
"linkMode": "imported_file",
"title": "mypdf.pdf",
"accessDate": "",
"note": "",
"tags": [],
"collections": [],
"relations": {},
"contentType": "",
"charset": "",
"filename": "/path/to/mypdf.pdf",
"md5": "None",
"mtime": "None",
"parentItem": "WKC6M5SL",
"key": "XR23RHQI"
}
]
}
from pyzotero.
I have the original file path, is that normal? Should it not be the zotero storage path /path/to/Zotero/storage
No, the file path that's returned should match your local file path. But from your output above, the dict is in the wrong key: it's in unchanged
, and if the file is successfully uploaded (and possibly attached to a parent item), it should be under success
.
from pyzotero.
Related Issues (20)
- There has an question of this code HOT 1
- pyzotero.zotero_errors.HTTPError: Code: 500 HOT 6
- update_items() only processes the first chunk (50 items) HOT 2
- How to get notes associated with a journal entry? HOT 2
- API Limits? HOT 4
- retrieving items from subcollections HOT 2
- get_subset does not return actual data
- Can't attach note to item HOT 3
- Deleting a note HOT 3
- Are new Zotero beta notes and annotations (not saved in the PDF) retrievable in Pyzotero? HOT 6
- HTTP response is stored in Zotero.request property
- report requests.exceptions.HTTPError: 403, when use attachment_simple() function HOT 1
- Can't retrieve groups metadata.
- Feature Request - Add tags and modify comments of annotations HOT 8
- Missing git tag for 1.5.3 HOT 2
- How can I access the link of an attachment file in Zotero and update it? HOT 4
- Using search/request parameters HOT 2
- Software itemType HOT 2
- Wrong documentation for combining tags via logical "OR" operator?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyzotero.