Skip to main content

Uploading files

Uploading a file for a placeholder requires using one of the returned uploadEndpoints where the endpointType is HTTP (i.e. 0).

The uploadEndpoints are specified in the response from a Document GET request or from the returned document after a placeholder document is created.

{
"uploadEndpoints": [
{
"location": "https://client-api.phlextmf.com/documents/v5/Files/155",
"endpointType": 0,
"params": {}
}
],
"downloadEndpoints": [
{
"pdfLocation": "https://client-api.phlextmf.com/documents/v5/Files/155?native=false&watermark=false",
"pdfWatermarkLocation": "https://client-api.phlextmf.com/documents/v5/Files/155?native=false&watermark=true",
"nativeLocation": "https://client-api.phlextmf.com/documents/v5/Files/155?native=true",
"endpointType": 0,
"params": null
}
]
}

HTTP Upload

The /documents/v5/files URI is the default endpoint for uploading of files.

Sending a HTTP upload

  1. Create a PUT request to the API's /documents/v5/files URI. For example:

    PUT https://client-api.phlextmf.com/documents/v5/files/{documentId}

  2. Add the following top-level HTTP headers:

    • Content-Type. Set to match the type of file being uploaded,i.e. application/pdf when uploading a PDF.
    • Authorization. Set to the JWT bearer token.
    • Filename. Set to the file name which should be saved to the TMF.
  3. Create the body of the request containing the binary data of the file to upload.

  4. Send the request.

Example of a HTTP upload

PUT /documents/v5/files/155
content-type: application/pdf
authorization: bearer {{auth.response.body.access_token}}
filename: Test.pdf

Binary Data

If the request succeeds, a HTTP 204 status code is returned indicating success.

Legacy Multipart Upload

Note: The multipart upload process is to be used for PhlexTMF versions prior to v21.0.

The /Document/UploadDocument URI is the legacy endpoint for uploading of files. The default mechanism for upload allows you to send the documentId parameter and file as part of a multipart upload POST. This option is suitable for data files that are small enough to upload again in its entirety, as if the connection fails the upload cannot be resumed.

Sending a multipart upload

  1. Create a POST request to the website's /Document/UploadDocument URI. For example:

    POST https://client.phlextmf.com/Document/UploadDocument

  2. Create the body of the request. Format the body according to the multipart/form-data with a defined multipart bounday. The request must contain 2 parts:

    1. File part. This must be named "placeholderFile" and must come first, and must have a Content-Type header set to the MIME type of the file being sent.
    2. Document Id part. This must be named "documentId" and must come second.
  3. Separate each part with a boundary string ensuring two hyphens after the final boundary string.

  4. Add the following top-level HTTP headers:

    • Content-Type. Set to multipart/form-data, and include the boundary string used to identify the different parts of the request.
    • Content-Length. Set to the total number of bytes in the request body.
    • Authorization. Set to the JWT bearer token.
  5. Send the request.

Example of a multipart upload

POST /Document/UploadDocument HTTP/1.1 
Authorization: bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Cache-Control: no-cache
Content-Length: 84488
Content-Type: multipart/form-data; boundary=----PartBoundary7MA4YWxkTrZu0gW

------PartBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="placeholderFile"; filename="Test.pdf"
Content-Type: application/pdf
\[File Data\]
------PartBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="documentId"

118118
------PartBoundary7MA4YWxkTrZu0gW--

If the request succeeds, a HTTP 200 status code is returned along with the JSON response indicating success.

{"Status":1}