Following are the other common reasons for broken output links.
Link is accessed after expiration period
By default PDF.co response links are accessible for 1 hour. After that duration, the file is removed from PDF.co cloud and links are expired.
However, one can adjust expiration parameters on request as per requirement.
Async Job is created and it’s success status is not checked
All PDF.co requests can be executed in asynchronous mode by setting async
parameter value to true
. This asynchronous request returns a jobId as well as an output URL in response.
Now, This URL won’t be ready and publicly accessible unless the job is checked by job/check
request and it has success
status.
API response does not pass through JSON parser/decoder
Most of the request clients have a built-in JSON parser/decoder. For security reasons, PDF.co response by-default contains the encrypted file url link this.
{
"url": "https://pdf-temp-files.s3.us-west-2.amazonaws.com/D0VXAHON7B4WALKOVR2NIUM2ERRPPYI3/sample2.pdf?X-Amz-Expires=3600&X-Amz-Security-Token=FwoGZXIvYXdzEK%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaDEbAXxnsfmdl03uy1SKCAR%2B1xIlLYex45jB2WWJvynVJZ8l3dQWfQEmMxKIJJWsBexPViHm8HHD5X6zxCTaw7kmtJjfiKwp6QclRO%2BGa9%2B5VYLWEVP5n88%2B1YPeGwHVkD%2F%2FtUUdJ7jZuFJ6TUurGS%2FIdklxFnC2c9XBcEUunp5bnf5PuNLde38SnndtuCK%2B%2B9UAo6bqIlwYyKBbUA7YQZAFVN6XkG%2ByGzjmvq1UI149EBOdhilHaR6EaZlMYnfV1V4s%3D&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIA4NRRSZPHPS55AP5S/20220728/us-west-2/s3/aws4_request&X-Amz-Date=20220728T053316Z&X-Amz-SignedHeaders=host&X-Amz-Signature=0c16c754e310e8229f0b5a31f928cc6e432b53ed7d9957dd59b23d4b187c9dfd",
For most scenarios, this URL will be accessible without issue as it’ll be through JSON parser/decoder.
However, when a request is made by clients which does not have built-in JSON parser/decoder (example cURL), it’ll show a raw response and the user might be confused with a link appearing as broken.
For example, a cURL response would be like the following.
{"url":"https://pdf-temp-files.s3.us-west-2.amazonaws.com/D0VXAHON7B4WALKOVR2NIUM2ERRPPYI3/sample2.pdf?X-Amz-Expires=3600\u0026X-Amz-Security-Token=FwoGZXIvYXdzEK%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaDEbAXxnsfmdl03uy1SKCAR%2B1xIlLYex45jB2WWJvynVJZ8l3dQWfQEmMxKIJJWsBexPViHm8HHD5X6zxCTaw7kmtJjfiKwp6QclRO%2BGa9%2B5VYLWEVP5n88%2B1YPeGwHVkD%2F%2FtUUdJ7jZuFJ6TUurGS%2FIdklxFnC2c9XBcEUunp5bnf5PuNLde38SnndtuCK%2B%2B9UAo6bqIlwYyKBbUA7YQZAFVN6XkG%2ByGzjmvq1UI149EBOdhilHaR6EaZlMYnfV1V4s%3D\u0026X-Amz-Algorithm=AWS4-HMAC-SHA256\u0026X-Amz-Credential=ASIA4NRRSZPHPS55AP5S/20220728/us-west-2/s3/aws4_request\u0026X-Amz-Date=20220728T053316Z\u0026X-Amz-SignedHeaders=host\u0026X-Amz-Signature=0c16c754e310e8229f0b5a31f928cc6e432b53ed7d9957dd59b23d4b187c9dfd"
Please notice the character '\u0026
' in response. Normally after JSON decoding this would be replaced with '&
'. Now, cURL does not have a built-in JSON parser/decoder and it shows raw responses.If this un-parsed raw link is directly utilized it’ll appear as broken.
Use "name" parameter to get custom filename
name
parameter works on most of API endpoints that return files in output.
For example, pdf/edit/add
API endpoint by default returns the filename of the original file, You can modify filename by adding name
parameter in request e.g "name": "filename_here",
.
Response Body:
{
"hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"url": "https://pdf-temp-files.s3.us-west-2.amazonaws.com/MYSLQJEX0Y3SIEW9FMQY2KT0H39XB09A/filename_here?X-Amz-Expires=3600&X-Amz-Security-Token=FwoGZXIvYXdzEN7%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaDPiE4L2emq58D5Nq%2FCKCAdxB1sOgSf7Euq%2FPnwiUfmqfheDr0zAcvZFOVwH12XGuEHgO1QpyuF3rB%2Bnp0%2Fs1Y28ssKQnbSpEA2Kqnqtqd7V8h0FTBmkUTBLNzrFVuygjbMA%2FNP5fYqybQ5bQHrTrH%2FenyjMydpVR7RPhgnrNV7Vc71XsCMJLNw%2BUK1NGp4c4KHgonMrenQYyKKFu5FyKltXsOnGXW3upduOI3qHM2%2BavfkVsmQRCROuabLCMIwTzOB8%3D&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIA4NRRSZPHIQZMGGRJ/20230106/us-west-2/s3/aws4_request&X-Amz-Date=20230106T071940Z&X-Amz-SignedHeaders=host&X-Amz-Signature=67ac6cef6b8bb3aae652e9f942c4667c809e3389016386f3f7f4d6f8f99d1999",
"pageCount": 1,
"error": false,
"status": 200,
"name": "filename_here",
"credits": 21,
"duration": 277
}