Excerpt |
---|
Giles provides REST endpoints to specific functionality such as uploading or retrieving images. The following sections describe all so far available endpoints, their parameters, and what they return. |
Add files to Giles
In theory, you can add any file type you want to Giles. However, only file types supported by Digilib or file types that Giles knows how to convert really make sense. Currently, Giles knows how to convert PDFs to images. Giles is globally configurable in regards to what image type it uses and what DPI when converting PDFs to images (default is tiff/600 dpi). Giles will create one image per PDF page and put all images together into one folder so that you can use Digilib's paginator feature. The original PDF is stored separately outside of Digilib's image folder.
...
accessToken: a github access token that is used to authenticate the uploading user
access (optional): access policy for uploaded files; possible values are are PRIVATE or or PUBLIC; default is PRIVATE PRIVATE.
document_type (optional): specifies if uploaded files are several pages of the same document (MULTI_PAGE) or if they should be uploaded as separate documents (SINGLE_PAGE); default is SINGLE_PAGE.
files: the files to be uploaded
v0.6 and newer
Giles will respond with an progress id and a url to check the progress of the upload:
Code Block |
---|
|
{
"id":"PROGQ3Fm2J",
"checkUrl":"http://your-giles-org.net/giles/rest/files/upload/PROGQ3Fm2J"
} |
You can now poll the url provided as 'checkUrl'. As long as the upload hasn't finished yet, you will get a 202 Accepted response with the following response body:
Code Block |
---|
|
{
"msg":"Upload in progress. Please check back later.",
"msgCode":"010"
} |
Once uploading has finished, you will retrieve the complete information:
Code Block |
---|
language | js |
---|
title | Upload Image Sample Response from Giles |
---|
|
[ {
"documentId" : "DOC123edf",
"uploadId" : "UPxx456",
"uploadedDate" : "2016-09-20T14:03:00.152Z",
"access" : "PRIVATE",
"uploadedFile" : {
"filename" : "uploadedFile.pdf",
"id" : "FILE466tgh",
"url" : "http://your-giles-host.net/giles/rest/files/FILE466tgh/content",
"path" : "username/UPxx456/DOC123edf/uploadedFile.pdf",
"content-type" : "application/pdf",
"size" : 3852180
},
"extractedText" : {
"filename" : "uploadedFile.pdf.txt",
"id" : "FILE123cvb",
"url" : "http://your-giles-host.net/giles/rest/files/FILE123cvb/content",
"path" : "username/UPxx456/DOC123edf/uploadedFile.pdf.txt",
"content-type" : "text/plain",
"size" : 39773
},
"pages" : [ {
"nr" : 0,
"image" : {
"filename" : "uploadedFile.pdf.0.tiff",
"id" : "FILEYUI678",
"url" : "http://your-giles-host.net/giles/rest/digilib?fn=username%FILEYUI678%2FDOC123edf0%2FuploadedFile.pdf.0.tiff",
"path" : "username/UPxx456/DOC123edf/uploadedFile.pdf.0.tiff",
"content-type" : "image/tiff",
"size" : 2032405
},
"text" : {
"filename" : "uploadedFile.pdf.0.tiff.txt",
"id" : "FILE789UIO",
"url" : "http://your-giles-host.net/giles/rest/files/FILE789UIO/content",
"path" : "username/UPxx456/DOC123edf/uploadedFile.pdf.0.tiff.txt",
"content-type" : "text/plain",
"size" : 4658
}
}, {
"nr" : 1,
"image" : {
"filename" : "uploadedFile.pdf.1.tiff",
"id" : "FILE045tyhG",
"url" : "http://your-giles-host.net/giles/rest/digilib?fn=username%2FFILE045tyhG%2FDOC123edf0%2FuploadedFile.pdf.1.tiff",
"path" : "username/UPxx456/DOC123edf/uploadedFile.1.tiff",
"content-type" : "image/tiff",
"size" : 2512354
},
"text" : {
"filename" : "uploadedFile.pdf.1.tiff.txt",
"id" : "FILEMDSPfeVm",
"url" : "http://your-giles-host.net/giles/rest/files/FILEMDSPfeVm/content",
"path" : "username/UPxx456/DOC123edf/uploadedFile.pdf.1.tiff.txt",
"content-type" : "text/plain",
"size" : 5799
}
} |
Uploads expire after 24 hours or after a server restart. If you request an expired upload or an upload that doesn't exist you will get a 404 response with the following response body:
Code Block |
---|
{
"errorCode" : "404",
"errorMsg" : "Upload does not exist."
} |
v0.5 and older
For each uploaded file, Giles responds with either "success": 0
(upload was successful), or "success": 1
(upload failed).
...