Onix & Asset Bulk upload (Files Resource)
The files resource provides an endpoint for bulk upload of files and metadata.
URL:
https://api.openpublishing.com/resource/v3/files
https://api.openpublishing.com/resource/v3/files/[ID]
For adding files, POST
to above URL with an multipart/form encoded body with the following parameters:
file
the file itselftype
of the file. Arbitrary string to control which importer will import the file, e.g.onix
orjats
. If not set, the type will be detected automatically.
Fields
The URL also supports GET
for retrieving information about uploaded files. It contains a JSON with the following fields:
File name
Original file_name
of uploaded file.
File size
Original file_size
of uploaded file.
Href
href
field contains the URL to download file.
Labels
labels
of file - at the moment read only.
Properties
Properties of file - at the moment read only.
Sha1
sha1
checksum of uploaded file..
Created
Unix created
when file was uploaded.
Processed
The processed
fields is a boolean indicating if a file was processed.
Error
Error message (technical). Can be null
or a string.
Type
type
of the file.
Module
The module
field is determining which asset processor whould pick up the upload. It not set, the module is autodetected. Possible values are:
onix
Onix 2.1 or Onix 3.0.jats
JATS files.bib
Bibtex files.asset
all other assets, e.g. PDFs, Epubs or JPGs.
Mime Type
The mime_type
field contains the mime type of the uploaded file.
Realm
realm
is the Open Publishing terminology for tenant. It contains a dict with _id
and name
and screenname
.
Products
Once processed, the products
field contains references to the imported products.
Example JSON
{
"_id": 524808,
"_links": {
"log": "https://api.openpublishing.com/resource/v3/files/524808/log",
"self": "https://api.openpublishing.com/resource/v3/files/524808"
},
"created": 1698844698,
"error": null,
"file_name": "onix-complete.xml",
"file_size": 301138,
"href": "https://api.openpublishing.com/rpc/v2/uploads/get/524808",
"labels": [],
"products": [],
"module": "asset",
"mime_type": "image/jpeg",
"processed": false,
"properties": {},
"realm": {
"_id": 23,
"_links": {
"self": "https://api.openpublishing.com/resource/v3/realms/23"
},
"name": "testpublisher",
"screenname": "Test Publisher"
},
"sha1": "ea41da3a48c64e1cf09408f369dade22b7fcadb5",
"status": "finished",
"timestamp": 1556116199,
"type": null
}