0% found this document useful (0 votes)
17 views12 pages

Test

Uploaded by

favij69565
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views12 pages

Test

Uploaded by

favij69565
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

5/10/24, 5:30 PM File Upload — pdf.

co documentation

 API  File Upload

File Upload
You can upload files as temporary files into PDF.co. Temporary files are stored for 1 hour
by default and then auto removed.
To store files permanently (pdf templates, images you want to reuse) please use PDF.co
Built-In Files Storage instead.
You can also use 3rd party cloud services:
Dropbox: you can use public link to a file from Dropbox.
Google Drive: you can use link to a file that was shared as anyone with a link .
Google Docs/Sheets/Slides: you can use a link to a document in Google Docs that
was shared as anyone with a link .
Any other cloud service that can store a file and provide a link to uploaded file.
 Note
IMPORTANT NOTE FOR GOOGLE DRIVE/DOCS users: free Google Drive/Docs
limits the number of requests to their files. If you use a link to file or document
from Google Drive or Google Drive then make sure you have no more than 5-10
requests per minute. Otherwise Google Drive returns no file or error page.

Temporary Files Upload


You can upload temporary files up to 2GB in size. Please note that to process these files
you should use async=true mode with data extraction and tools endpoints
Back to along
top with
/job/check to check status of background jobs you create.

Steps to Upload
This website File
uses cookies for functional and analytical
purposes. By continuing, you agree to our cookie use. I Agree
1. First, call /file/upload/get-presigned-url.
Please read our privacy policy for more It willinformation.
generate link for uploading
( presignedUrl ) and final link ( url
Skip). to main content
https://developer.pdf.co/api/file-upload/index.html 1/12
5/10/24, 5:30 PM File Upload — pdf.co documentation

2. Now send your file to the presignedUrl link using the PUT method within the next 30
minutes.
3. Once finished, use url to access the file you have just uploaded.
Note: all uploaded files are considered to be temporary files and are automatically
permanently removed after 1 hour.

Response Codes
Code Description
200 The request has succeeded.
400 Bad input parameters.
401 Unauthorized.
403 Not enough credits.
405 Timeout error. Use /file/upload/url for small
files (<500kb). For faster and stable file
uploads, use /file/upload/get-presigned-url
and the PUT workflow with /presignedUrl –
data-binary ‘sample.pdf’.

Available Methods
/file/upload/get-presigned-url
GET
PUT /presignedUrl –data-binary ‘sample.pdf’
POST /file/upload
POST /file/upload/base64
POST /file/upload/url
GET /file/upload/url
POST /file/delete
This website
POST /file/hashuses cookies for functional and analytical
purposes. By continuing, you agree to our cookie use.
Please read our privacy policy for more information.
GET /file/upload/get-presigned-url
Skip to main content
https://developer.pdf.co/api/file-upload/index.html 2/12
5/10/24, 5:30 PM File Upload — pdf.co documentation

This method generates links to upload your local file to. Use this presignedUrl from the
response to upload your file. Once you upload your file to this presignedUrl using PUT ,
you can use the url link to access the uploaded file.
With this method you can upload files up to 2GB in size. Please note that to process these
files you should use async=true mode with data extraction and tools endpoints along with
/job/check to check status of background jobs you create.
Method: GET
Endpoint: /v1/file/upload/get-presigned-url

Query parameters
Parameter name Description Example
name File name for the generated test.pdf
output, the input must be in
string format.
encrypt Whether to encrypt the file false

contentType The content type of the application/pdf


uploaded file

CURL
curl --location --request GET https://api.pdf.co/v1/file/upload/get-presigned-url?name=
--header 'x-api-key: YOUR_API_KEY'

EXAMPLE Response
{
"presignedUrl": "https://pdf-temp-files.s3.us-west-2.amazonaws.com/A1VGV42YE0NWXMKE

This website uses cookies for functional and analytical


"url": "https://pdf-temp-files.s3.us-west-2.amazonaws.com/A1VGV42YE0NWXMKEB4BUIWNYG
"error": false,
purposes. By continuing, you agree to our cookie use.
"status": 200,

Please read our privacy policy for more information.


"name": "test.pdf",
"credits": 7,
"duration": 0,
Skip to main content
https://developer.pdf.co/api/file-upload/index.html 3/12
5/10/24, 5:30 PM File Upload — pdf.co documentation
"remainingCredits": 98191146
}

See Response Codes.

PUT/presignedUrl –data-binary
‘sample.pdf’
With this method you can upload files up to 100mb in size. Please note that to process
these files you should use async=true mode with data extraction and tools endpoints
along with /job/check to check status of background jobs you create.
Method: PUT
Endpoint: your presignedUrl from /file/upload/get-presigned-url

Content-Type header
When sending PUT request don’t forget to add Content-Type header with proper value
based on input file type.
For example:
File Extension Content-Type Value
.txt .csv .xml .json text/plain

.pdf application/pdf

.msg .eml application/vnd.ms-outlook

.doc application/msword

 Note
If you’re not sure then use application/octet-stream header. It works for most file
types.
This website uses cookies for functional and analytical
purposes. By continuing, you agree to our cookie use.
Pleasefiles
All uploaded readareourtreated
privacyaspolicy for more
temporary files information.
and are automatically permanently
removed after 1 hour. If you have a file Skipthat
to main content
you want to reuse over and over, please upload
https://developer.pdf.co/api/file-upload/index.html 4/12
5/10/24, 5:30 PM File Upload — pdf.co documentation

it to PDF.co Built-In Files Storage and get its filetoken:// link that you may reuse inside
PDF.co API.

CURL
curl --location --request PUT '<insert presignedUrl here>' \
--header 'x-api-key: YOUR_API_KEY' \
--header 'Content-Type: application/octet-stream' \
--data-binary '@./sample.pdf'

EXAMPLE Response
{
"presignedUrl": "https://pdf-temp-files.s3-us-west-2.amazonaws.com/0c72bf56341142ba
"url": "https://pdf-temp-files.s3-us-west-2.amazonaws.com/0c72bf56341142ba83c8f98b4
"error": false,
"status": 200,
"name": "test.pdf",
"remainingCredits": 98145
}

See Response Codes.

POST /file/upload
Uploads a small (up to 100KB) local file as a temporary file in PDF.co storage. Note:
temporary files are automatically permanently removed after 1 hour.
Method: POST
Endpoint: /v1/file/upload

CURL
This website uses cookies for functional and analytical
purposes. By continuing, you agree to our cookie use.
curl --location --request POST 'https://api.pdf.co/v1/file/upload' \

Please read our privacy policy for more information.


--header 'x-api-key: ' \
--form 'file=@"/path/to/file"'

Skip to main content


https://developer.pdf.co/api/file-upload/index.html 5/12
Response
5/10/24, 5:30 PM File Upload — pdf.co documentation

EXAMPLE
{
"url": "https://pdf-temp-files.s3.amazonaws.com/1a4a92ac805c41c28ef75a24e0f35ba5/sa
"error": false,
"status": 200,
"name": "sample.pdf",
"remainingCredits": 98145
}

See Response Codes.

POST /file/upload/base64
Creates a temporary file using base64 source data. You may use this temporary file URL
with other API methods. Temporary files are automatically permanently removed after 1
hour.
Method: POST
Endpoint: /v1/file/upload/base64

CURL
curl --location --request POST 'https://api.pdf.co/v1/file/upload/base64' \
--header 'x-api-key: ' \
--form 'file="data:image/gif;base64,R0lGODlhEAAQAPUtACIiIScnJigoJywsLDIyMjMzMzU1NTc3Nzg

EXAMPLE Response
{
"url": "https://pdf-temp-files.s3.amazonaws.com/7588d614c9ad41eb98ec317a02abda63/up
"error": false,

This website uses cookies for functional and analytical


"status": 200,
"remainingCredits": 77769
}
purposes. By continuing, you agree to our cookie use.
Please read our privacy policy for more information.
Skip to main content
https://developer.pdf.co/api/file-upload/index.html 6/12
5/10/24, 5:30 PM File Upload — pdf.co documentation

See Response Codes.

POST /file/upload/url
Downloads file from a source url and uploads it as a temporary file. Temporary files are
automatically permanently removed after 1 hour.
Method: POST
Endpoint: /v1/file/upload/url

CURL
curl --location --request POST 'https://api.pdf.co/v1/file/upload/url' \
--header 'x-api-key: ' \
--form 'name="sample.pdf"' \
--form 'url="pdfco-test-files.s3.us-west-2.amazonaws.compdf-split/sample.pdf"'

EXAMPLE Response
{
"url": "https://pdf-temp-files.s3.amazonaws.com/1a4a92ac805c41c28ef75a24e0f35ba5/sa
"error": false,
"status": 200,
"name": "sample.pdf",
"remainingCredits": 98145
}

See Response Codes.

GET /file/upload/url
This website
Downloads file fromuses cookies
a source for functional
url and uploads itand
as aanalytical
temporary file. Temporary files are
purposes. By continuing, you agree to
automatically permanently removed after 1 hour.our cookie use.
Please read our privacy policy for more information.
Method: GET Skip to main content
https://developer.pdf.co/api/file-upload/index.html 7/12
5/10/24, 5:30 PM File Upload — pdf.co documentation

Endpoint: /v1/file/upload/url

CURL
curl --location --request GET 'https://api.pdf.co/v1/file/upload/url?url=pdfco-test-fil
--header 'x-api-key: '

EXAMPLE Response
{
"url": "https://pdf-temp-files.s3.amazonaws.com/97415d1c45a04b29ac42c8dc01883316/sa
"error": false,
"status": 200,
"name": "sample.pdf",
"remainingCredits": 77765
}

See Response Codes.

POST /file/delete
Deletes temporary file (that was uploaded by you or generated by API).
 Note
All temporary files are auto removed after 1 hour. You may use File Upload
methods to explicitly force remove temp files once you don’t need them.

Method: POST
Endpoint: /v1/file/delete

AttributesThis website uses cookies for functional and analytical


purposes. By continuing, you agree to our cookie use.
Please read our privacy policy for more information.
Skip to main content
https://developer.pdf.co/api/file-upload/index.html 8/12
5/10/24, 5:30 PM File Upload — pdf.co documentation

Attribute Description Required


url URL of the previously yes
uploaded temporary file or
output file that was
generated by the API
method.

Query parameters
No query parameters accepted.

EXAMPLE Payload
{
"url": "https://pdf-temp-files.s3.amazonaws.com/b5c1e67d98ab438292ff1fea0c7cdc9d/sa
}

EXAMPLE Response
{
"error": false,
"status": 200,
"remainingCredits": 9999986
}

See Response Codes.

CURL
curl --location --request POST 'https://api.pdf.co/v1/file/delete' \
--header 'x-api-key: ' \
--data-raw '{
This website uses cookies for functional and analytical
"url": "https://pdf-temp-files.s3.amazonaws.com/b5c1e67d98ab438292ff1fea0c7cdc9d/sa

purposes. By continuing, you agree to our cookie use.


}'

Please read our privacy policy for more information.


Skip to main content
https://developer.pdf.co/api/file-upload/index.html 9/12
5/10/24, 5:30 PM File Upload — pdf.co documentation

POST /file/hash
Calculate and return MD5 hash of file by url. Commonly used to control if the source
document has been changed or not because every little change will cause hash string to
differ as well.
Method: POST
Endpoint: /v1/file/hash

Attributes
Attribute Description Required
url URL to the source file. [1] yes

Query parameters
No query parameters accepted.

EXAMPLE Payload
{
"url": "pdfco-test-files.s3.us-west-2.amazonaws.compdf-split/sample.pdf"
}

EXAMPLE Response
{
"hash": "d942e5becdcb0386598cce15e9e56deb1ca9d893b8578a88eca4a62f02c4000b",
"remainingCredits": 98143
}

This website uses cookies for functional and analytical


See Response
purposes.Codes.
By continuing, you agree to our cookie use.
Please read our privacy policy for more information.
Skip to main content
https://developer.pdf.co/api/file-upload/index.html 10/12
CURL
5/10/24, 5:30 PM File Upload — pdf.co documentation

curl --location --request POST 'https://api.pdf.co/v1/file/hash' \


--header 'x-api-key: ' \
--data-raw '{
"url": "pdfco-test-files.s3.us-west-2.amazonaws.compdf-split/sample.pdf"
}'

Footnotes
[1] Supports links from Google Drive, Dropbox, and PDF.co Built-In Files Storage. To
upload files via the API check out the File Upload section. Note: If you experience
intermittent Too Many Requests or Access Denied errors, please try to add cache: to
enable built-in URL caching. (e.g cache:https://example.com/file1.pdf ) For data
security, you have the option to encrypt output files and decrypt input files. Learn
more about user-controlled data encryption.
2 Main response codes as follows:
Code Description
200 Success
400 Bad request. Typically happens because
of bad input parameters, or because the
input URLs can’t be reached, possibly
due to access restrictions like needing a
login or password.
401 Unauthorized
402 Not enough credits
445 Timeout error. To process large
documents or files please use
asynchronous mode (set the async
parameter to true ) and then check
status using the /job/check endpoint. If a
This website uses cookies for functional andfileanalytical
contains many pages then specify a
purposes. By continuing, you agree to our page
cookierange
use. using the pages parameter.
The number of pages of the document
Please read our privacy policy for more information.
Skip to main content
https://developer.pdf.co/api/file-upload/index.html 11/12
5/10/24, 5:30 PM File Upload — pdf.co documentation

Code Description
can be obtained using the /pdf/info
endpoint.

 Note
For more see the complete list of available response codes.

Was this page helpful? Yes No

© Copyright 2023 Artifex Software, Inc d/b/a PDF.co — All Rights Reserved Support

This website uses cookies for functional and analytical


purposes. By continuing, you agree to our cookie use.
Please read our privacy policy for more information.
https://developer.pdf.co/api/file-upload/index.html 12/12

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy