API to Upload File (Binary Upload) Documentation
This document provides an overview of the API to upload file, explaining its purpose, the functionality of each section, and how to use it to send HTTP requests.Purpose of the API
This API is designed to:- Act as a middleware service, processing incoming requests.
- Validate requests using an API key.
- Retrieve a file from a specified URL and forward it, along with other data, to a designated endpoint.
Step1: Configure the HTTP Request in Pabbly
- Navigate to the Pabbly Connect Developer platform and go to the "Actions" section to set up the action.
- Method: Set the method as POST.
- URL: Enter the URL "https://binary-fileupload.pabbly.workers.dev/ " in the "API Endpoint URL" section.
- Headers:
- Add a header pabbly_api_key with the value set to our API key.
- Set Content-Type to application/json.
- Body: Use JSON format to include the required parameters.
Step 2: Enter the JSON body.
{
"endpoint": "https://upload.heygen.com/v1/asset",
"file_url": "{{file_url}}",
"headers_to_forward": ["x-api-key"],
"method": "POST"
}
JSON Body Parameters:
endpoint: It is the API endpoint of the application you want to configure.
file_url: It is the file URL entered by the user.
Headers_to_forward: Enter the array of headers or a single string comma-separated headers in a single string.
E.g. "headers_to_forward": ["Header1", "Header2", "Header3"] or
"headers_to_forward": "Header1, Header2, Header3".
method: The HTTP method to use when forwarding the file (POST, PUT, etc.).
content_type: You can provide the content type if it is fixed for the entire endpoint. If it is not fixed then do not include it in the JSON Body as the worker code will fetch it automatically from the file_url.
Sample cURL:
Code:
curl -X POST "https://binary-fileupload.pabbly.workers.dev/" \
-H "pabbly_api_key: {{pabbly_api_key}}" \
-H "Authorization: Bearer your_auth_token" \
-H "Content-Type: application/json" \
-d '{
"endpoint": "https://app.recut.in/api/files/upload/filename.png",
"file_url": "https://www.pabbly.com/wp-content/uploads/2023/01/Pabbly.png",
"headers_to_forward": ["Authorization"],
"method": "POST",
"content_type": "application/json"
}'
file_url parameter conditions:
- The file_url can be a direct URL. E.g.
- The file_url can be a direct downloadable drive URL. E.g. https://drive.google.com/uc?export=download&id=1Pn5_9X1JK08t7mw5LR6CnyNes_aAMViy or
https://docs.google.com/spreadsheet...TCfbyoz92Jcl0xyt0cRecM3Ecw/export?format=xlsx
- The file_url can be a direct downloadable Dropbox URL. In the case of a normal Dropbox URL, set the value of the ‘dl’ parameter to 1. E.g. https://www.dropbox.com/scl/fi/orsk...ey=4z45zix70yzh5p4sv9cj4f2os&st=2os6wma0&dl=1
Parameter | Type | Description | Example Value |
pabbly_api_key | Header | An authentication key is needed to validate worker access. It should match the predefined key set in the worker code. | pabbly_api_key: {{PabblyPrivateKeyForInternalUse}} NOTE: This key is only used for our internal development for now. |
Authorization | Header | Custom header to forward to the target endpoint for further authentication, if required. | Authorization: {{Bearertokenofapplication}} |
Content-Type | Header | Defines the content type of the data being uploaded, such as application/json. | Content-Type: application/json |
endpoint | JSON Field | Specifies the destination endpoint where the file should be uploaded. Accepts the file path with placeholders for the file name. | "https://target-endpoint.com/api/files/upload/:filename.jpeg" |
file_url | JSON Field | URL of the file to be fetched and uploaded to the destination endpoint. The file is downloaded by the worker before being forwarded. |
|
headers_to_forward | JSON Field | An array of headers to be forwarded from the initial request to the destination endpoint. Useful for passing tokens or other sensitive information. | ["Authorization"] |
method | JSON Field | Specifies the HTTP method for the request to the destination endpoint. Accepted values are POST, PUT, etc. | "POST" |
NOTE:
In the case of Canva. The filename is to be passed as Base64. To do so, we can either take the name as encoded base64 from the user or we can create the same with the help of Select Transform and Multistep action as shown below:
Here, the Base64 converted filename is passed as from the action event.
Last edited: