====== Zotero Web API File Uploads ======
In addition to providing ways to [[basics#read_requests|read]] and [[write_requests|write]] online library data, the Zotero Web API allows you to upload attachment files.
The exact process depends on whether you are adding a new attachment file or modifying an existing one and whether you are performing a full upload or uploading a binary diff.
===== 1a) Create a new attachment =====
==== i. Get attachment item template ====
GET /items/new?itemType=attachment&linkMode={imported_file,imported_url,linked_file,linked_url}
{
"itemType": "attachment",
"linkMode": "imported_url",
"title": "",
"accessDate": "",
"url": "",
"note": "",
"tags": [],
"relations": {},
"contentType": "",
"charset": "",
"filename": "",
"md5": null,
"mtime": null
}
==== ii. Create child attachment item ====
POST /users//items
Content-Type: application/json
Zotero-Write-Token:
[
{
"itemType": "attachment",
"parentItem": "ABCD2345",
"linkMode": "imported_url",
"title": "My Document",
"accessDate": "2012-03-14T17:45:54Z",
"url": "http://example.com/doc.pdf",
"note": "",
"tags": [],
"relations": {},
"contentType": "application/pdf",
"charset": "",
"filename": "doc.pdf",
"md5": null,
"mtime": null
}
]
''md5'' and ''mtime'' can be edited directly in personal libraries for WebDAV-based file syncing. They should not be edited directly when using Zotero File Storage, which provides an atomic method (detailed below) for setting the properties along with the corresponding file.
Top-level attachments can be created by excluding the ''parentItem'' property or setting it to ''false''. Though the API allows all attachments to be made top-level items for backward-compatibility, it is recommended that only file attachments (''imported_file''/''linked_file'') and PDF imported web attachments (''imported_url'' with content type ''application/pdf'') be allowed as top-level items, as in the Zotero client.
===== 1b) Modify an existing attachment =====
==== i. Retrieve the attachment information ====
GET /users//items/
{
"key": "ABCD2345",
"version": 124,
"library": { ... },
...
"data": {
"key": "ABCD2345",
"version": 124,
"itemType": "attachment",
"linkMode": "imported_file",
"title": "My Document",
"note": "",
"tags": [],
"relations": {},
"contentType": "text/plain",
"charset": "utf-8",
"filename": "doc.txt",
"md5": "4fa38e3f2c360ca181e633d02bab91f5",
"mtime": "1331171741767"
}
}
==== ii. Download the existing file ====
GET /users//items//file
Check the ''ETag'' header of the response to make sure it matches the attachment item's ''md5'' value. If it doesn't, check the attachment item again. If the attachment item still has a different hash, the latest version of the file may be available only via WebDAV, not via Zotero File Storage, and it is up to the client how to proceed.
Save the file as ''filename'' and set the modification time to the ''mtime'' provided in the attachment item.
==== iii. Make changes to the file ====
Note that to perform a faster partial upload using a binary diff, you must save a copy of the file before changes are made.
===== 2) Get upload authorization =====
POST /users//items//file
Content-Type: application/x-www-form-urlencoded
If-None-Match: *
md5=&filename=&filesize=&mtime=
For existing attachments, use ''If-Match: '' in place of ''If-None-Match: *'', where is the previous MD5 hash of the file (as provided in the ''ETag'' header when downloading it).
Note that ''mtime'' must be provided in milliseconds, not seconds.
A successful ''200'' response returns one of two possible JSON objects:
{
"url": ...,
"contentType": ...,
"prefix": ...,
"suffix": ...,
"uploadKey": ...
}
or
{ "exists": 1 }
In the latter case, the file already exists on the server and was successfully associated with the specified item. No further action is necessary.
^ Common responses ^^
| ''200 OK'' | The upload was authorized or the file already exists. |
| ''403 Forbidden'' | File editing is denied. |
| ''409 Conflict'' | The target library is locked. |
| ''412 Precondition Failed'' | The file has changed remotely since retrieval (i.e., the provided ETag no longer matches). Conflict resolution is left to the client. |
| ''413 Request Entity Too Large'' | The upload would exceed the storage quota of the library owner. |
| ''428 Precondition Required'' | If-Match or If-None-Match was not provided. |
| ''429 Too Many Requests'' | Too many unfinished uploads. Try again after the number of seconds specified in the ''Retry-After'' header. |
===== 3a) Full upload =====
==== i. POST file ====
Concatenate ''prefix'', the file contents, and ''suffix'' and POST to ''url'' with the ''Content-Type'' header set to ''contentType''.
''prefix'' and ''suffix'' are strings containing multipart/form-data. In some environments, it may be easier to work directly with the form parameters. Add ''params=1'' to the upload authorization request above to retrieve the individual parameters in a ''params'' array, which will replace ''contentType'', ''prefix'', and ''suffix''.
^ Common responses ^^
| ''201 Created'' | The file was successfully uploaded. |
==== ii. Register upload ====
POST /users//items//file
Content-Type: application/x-www-form-urlencoded
If-None-Match: *
upload=
For existing attachments, use ''If-Match: '', where is the previous MD5 hash of the file, provided as the ''md5'' property in the attachment item.
^ Common responses ^^
| ''204 No Content'' | The upload was successfully registered. |
| ''412 Precondition Failed'' | The file has changed remotely since retrieval (i.e., the provided ETag no longer matches). |
After the upload has been registered, the attachment item will reflect the new metadata (''filename'', ''mtime'', ''md5'').
===== 3b) Partial upload =====
PATCH /users//items//file?algorithm={xdelta,vcdiff,bsdiff}&upload=
If-Match:
For best results, we recommend using Xdelta version 3 with the "''-9 -S djw''" flags. bsdiff takes significantly longer to generate diffs. 'vcdiff' is an alias for 'xdelta', as Xdelta3 can process diffs in VCDIFF format.
Clients may wish to automatically fall back to a full upload — possibly with some form of warning — if HTTP PATCH is not supported by a user's proxy server (indicated, in theory, by a ''405 Method Not Allowed'').
After the upload has finished, the attachment item will reflect the new metadata.
^ Common responses ^^
| ''204 No Content'' | The patch was successfully applied. |
| ''409 Conflict'' | The target library is locked; the patched file does not match the provided MD5 hash or file size |
| ''428 Precondition Required'' | If-Match or If-None-Match was not provided. |
| ''429 Too Many Requests'' | Too many unfinished uploads. Try again after the number of seconds specified in the ''Retry-After'' header. |Among the most interesting of Plutarch’s religious writings is one entitled On the Delays in the Divine Vengeance. As might be expected from the name, it deals with a problem closely akin to that which ages before had been made the subject of such sublime imagery and such inconclusive reasoning by the author of the Book of Job. What troubled the Hebrew poet was the apparently undeserved suffering of the just. What the Greek moralist feels himself called on to explain is the apparent prosperity and impunity of the wicked. He will not for a moment admit that crime remains unavengeful; his object is to show why the retribution does not follow directly on the deed. And, in order to account for this, he adduces a number of very ingenious reasons. By acting deliberately rather than in blind anger, the gods wish to read us a useful lesson in patience and forbearance. Sometimes their object is to give the sinner an opportunity for repentance and amendment; or else they may be holding him in reserve for the performance of some beneficial work. At other times, their justice is delayed only that it may be manifested by some signal and striking form of retribution. In many cases, the final stroke has been preceded by long years of secret torment; and even where no suffering seems to be inflicted, the pangs of remorse may furnish a sufficient expiation. Or again, vengeance may be reserved for a future generation. Some persons hold that to267 visit the sins of the fathers on the children is unjust, but in this they are profoundly mistaken. Members of the same family and citizens of the same state are connected as parts of one organic whole; sharing in the benefits which accrue from the good deeds of their predecessors, it is right that they should also share in the responsibility for their crimes. Moreover, the posterity of the wicked inherit a sinful disposition which, as the gods can clearly foresee, would betray itself in overt acts were they not cut off in their youth. And it is equally an error to suppose that the original wrongdoers remain unaffected by the retribution which befalls their descendants. On the contrary, they witness it from the next world, where it adds poignancy to their remorse, and entails on them fresh penalties over and above those which they have already been doomed to suffer. This preference of pure abstract speculation to beneficent290 action may be traced to the influence of Aristotle. Some of the most enthusiastic expressions used by Plotinus in speaking of his supreme principle seem to have been suggested by the Metaphysics and the last book of the Nicomachean Ethics. The self-thinking thought of the Stagirite does not, indeed, take the highest rank with him. But it is retained in his system, and is only relegated to a secondary place because, for reasons which we shall explain hereafter, it does not fulfil equally well with Plato’s Idea of Good, the condition of absolute and indivisible unity, without which a first principle could not be conceived by any Greek philosopher. But this apparent return to the standpoint of the Republic really involves a still wider departure from its animating spirit. In other words, Plotinus differs from Aristotle as Aristotle himself had differed from Plato; he shares the same speculative tendency, and carries it to a greater extreme. "Yes?" she answered, and stroked the head of the fawn. She dropped beside him and tried to hold him down. "He did not know I was coming here," she pleaded. "It was a mistake, Jack! Will you wait until I tell you? Will you wait?" She was clinging around his neck and would not be shaken off. He dragged her in the dust, trying to get free himself. Feeling entirely at ease, he climbed into the car, with a copy of the Cincinnati Gazette, which he had bought of a newsboy, lighted his pipe, put on his spectacles, and settled down to a labored, but thorough perusal of the paper, beginning at the head-lines on the upper left-hand corner, and taking in every word, advertisements and all, as systematically as he would weed a garden-bed or milk a cow. The Deacon never did anything slip-shod, especially when he had to pay 10 cents for a copy of the Cincinnati Gazette. He was going to get his full money's worth, and if it was not in the news and editorials, he would take it out of the advertisements and patent medicine testimonials. He was just going through a convincing testimonial to the manifold virtues of Spalding's Prepared Glue, when there was a bump, the sound of coupling, and his car began to move off. Little Sammy Woggles came out presently to get some wood. Shorty called him to him. There was something fascinatingly mysterious in his tones and actions to that youth, who devoured dime novels on the sly. "GREAT Jehosephat, how hungry I am," suddenly ejaculated Shorty, stopping his cheering, as the thunder of the guns died away into an occasional shot after the rebels galloping back to the distant woods on the ridge from which they had emerged. "It isn't funny, Albin," Dodd said woodenly. "It isn't a game." "Who fill their pockets at Scott's Float, "No—I d?an't say it. I did write 'em. But it's all your fault that I did—so you've no right to miscall me." Alice Jury said nothing, and Reuben began to feel vaguely uncomfortable. What queer eyes she had!—they seemed to bore into him like nails. He suddenly rose to his feet. "Where's master?" "Now, lads, to your homes," cried Turner, as they hurried on, "every man of ye. Go by different roads, and you will not be suspected. There is not a man they can swear to but myself. Now, brave hearts, farewell! We may not meet together again: but all the harm I wish ye is, that Calverley and I may soon meet; and if ever he plagues free man or bond among ye after that, say Wat Turner is a coward—Away! Tom Merritt," said he, drawing the mason aside, "do you think of leaving Winchcombe?—you know there are always busy tongues." HoME美女护士性交不雅照
ENTER NUMBET 0017
fente8.net.cn
www.yzclpj.com.cn
www.nafa9.net.cn
timu3.net.cn
www.erma4.com.cn
mita2.com.cn
www.guiye7.com.cn
lacan5.net.cn
manna8.net.cn
huizu0.com.cn