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
Create a
PUT
request to the API's/documents/v5/files
URI. For example:PUT https://client-api.phlextmf.com/documents/v5/files/{documentId}
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.
Create the body of the request containing the binary data of the file to upload.
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
Create a
POST
request to the website's/Document/UploadDocument
URI. For example: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:- 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. - Document Id part. This must be named "documentId" and must come second.
- File part. This must be named "placeholderFile" and must come first, and must have a
Separate each part with a boundary string ensuring two hyphens after the final boundary string.
Add the following top-level HTTP headers:
Content-Type
. Set tomultipart/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.
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}