Document types

Type Description
public document with public access
private only certain users have access to the document of this type

Upload document

Uploads document to the storage service. The uploading process is accomplished via multipart/form-data.
Allowed content types: text/html, application/pdf, image/png, image/jpeg

Form-data fields:

Field Description
file Content of the document
file[attributes] json with the document's attributes

Document attributes:

Field Description
document_type one of values from the document-types
owners array of owners account ids

Request:

  • POST /documents
    Content-Type:'multipart/form-data'

Example of file[attributes]

{
    "document_type": "private", 
    "owners": ["GBZ23MX4GBC2LTGOXLDXTKEIPWRE6XB56QD2CT4KOCV3YKM7VZTHTO22"],
    "expires": "30d"
}

Responses:

  • 201 Created

    {
      "data": {
          "type": "documents",
          "id": "ddbf6759629ca5d2754a4c9d.pdf",
          "attributes": {
              "file_name": "EASTImage.pdf",
              "owners": [
                  "GBZ23MX4GBC2LTGOXLDXTKEIPWRE6XB56QD2CT4KOCV3YKM7VZTHTO22"
              ],
              "s3link": "https://shelf-dev-docs.s3.eu-west-1.amazonaws.com/ddbf6759629ca5d2754a4c9d.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJ7OMTLLYCEVH7YEQ%2F20180830%2Feu-west-1%2Fs3%2Faws4_request&X-Amz-Date=20180830T145422Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=2981b42d38e4201c4fa123e312a4ab45bab908b078f4d56b524d95f9f4f6adec"
          },
          "links": {
              "self": "/documents/ddbf6759629ca5d2754a4c9d.pdf"
          }
      }
    }
    
  • 400(Bad Request) Returned when file has wrong type, document_type is invalid (see document types) or document_type is private but owners is empty.

Get document

Get aws s3 link to the document. This endpoint does not require auth for public documents. private documents are accessed by one of the owners.

Request:

  • GET /documents/{id}

Responses:

  • 200 OK
{
    "data": {
        "type": "documents",
        "id": "4b604b1e8e20f2c96e5e27ab.pdf",
        "attributes": {
            "file_name": "HTTP_Succinctly.pdf",
            "owners": null,
            "s3link": "https://shelf-dev-docs.s3.eu-west-1.amazonaws.com/4b604b1e8e20f2c96e5e27ab.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJ7OMTLLYCEVH7YEQ%2F20180830%2Feu-west-1%2Fs3%2Faws4_request&X-Amz-Date=20180830T151618Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=01934f42d1200059e8dcd97c0367f4ae01083c97d900229e5ae0fb6b1c9a5f9d"
        },
        "links": {
            "self": "/documents/4b604b1e8e20f2c96e5e27ab.pdf"
        }
    }
}
  • 404 Not found document with id not found.

  • 401 Unauthorized returned when a private document is accessed by not the document's owner.

Index documents

Get list of documents.

Field Description
in required array of document ids
page[number] number of the page starting from 0
page[size] size of the page (default 10)

Note: This endpoint will return only private documents owned by an account that has signed the request.

Request:

  • GET /documents?in=9996d6041f9020ffd60f8d13,83986ad25054ddbf19f993e1,a86b0cefdd80b1b9aa6bac20

Responses:

  • 200 OK
{
    "data": [
        {
            "type": "documents",
            "id": "9996d6041f9020ffd60f8d13",
            "attributes": {
                "created_at": "2018-11-16T17:38:01Z",
                "expires_at": "2018-12-16T19:38:01Z",
                "file_name": "image",
                "owners": null,
                "s3link": ""
            },
            "links": {
                "self": "/documents/9996d6041f9020ffd60f8d13"
            }
        },
        {
            "type": "documents",
            "id": "83986ad25054ddbf19f993e1",
            "attributes": {
                "created_at": "2018-11-16T17:39:52Z",
                "expires_at": "2018-12-16T17:39:52Z",
                "file_name": "image",
                "owners": null,
                "s3link": ""
            },
            "links": {
                "self": "/documents/83986ad25054ddbf19f993e1"
            }
        },
        {
            "type": "documents",
            "id": "a86b0cefdd80b1b9aa6bac20",
            "attributes": {
                "created_at": "2018-11-16T17:51:14Z",
                "expires_at": "2018-12-16T17:51:14Z",
                "file_name": "image",
                "owners": null,
                "s3link": ""
            },
            "links": {
                "self": "/documents/a86b0cefdd80b1b9aa6bac20"
            }
        }
    ],
    "links": {
        "first": "/documents?page%5Bnumber%5D=1&page%5Bsize%5D=10",
        "last": "/documents?page%5Bnumber%5D=1&page%5Bsize%5D=10",
        "next": "/documents?page%5Bnumber%5D=1&page%5Bsize%5D=10",
        "self": "/documents"
    },
    "meta": {
        "on_page": 10,
        "total_items": 3
    }
}
  • 401 Unauthorized one of the documents from the field in is now owned by signing accounts.

results matching ""

    No results matching ""