Upload file
Function: Upload file
This action allows you to effortlessly connect to an external system's API and upload a file. It simplifies data integration by providing a user-friendly, code-free interface to send files, enhancing the functionality of your applications. Whether you need to send documents, images, or any other file type, this action handles the technical details of API communication, including authentication and different upload methods.
Input
- Authentication method: Choose how you want to securely connect to the external API.
- Basic authentication: A simple method where you provide a username and password.
- Bearer Token: A token that grants access to API resources, sent with a "Bearer" prefix.
- API Token: A token that grants access to specific API endpoints, sent with a "Token" prefix.
- None: No authentication will be attempted.
- Default value: None
- Username: (Only visible if "Basic authentication" is selected) The username for basic authentication.
- Password: (Only visible if "Basic authentication" is selected) The password for basic authentication.
- Token: (Only visible if "Bearer Token" or "API Token" is selected) The token for Bearer or API Token authentication.
- Type of upload: Decide how the file should be sent to the API.
- Form post: Uploads the file as part of a multi-part form, suitable for sending files along with other data.
- Binary post: Uploads the file directly as raw binary data, often used for simple file transfers.
- Default value: Form post
- Headers: Custom headers you want to include in the API call. These are key-value pairs that provide additional information about the request.
- Endpoint: The complete URL of the external API where the file should be uploaded.
- Method: The HTTP method to use for the upload.
- PUT: Typically used to update an existing resource or create one if it doesn't exist.
- POST: Typically used to create a new resource.
- Default value: POST
- Query parameters: Key-value pairs that will be added to the end of the endpoint URL (e.g.,
?param1=value1¶m2=value2). - Request body: (Primarily for "Form post" type) Additional data (key-value pairs) to send along with the file in the request body.
- File: The actual file you wish to upload.
- Response format: Define the expected structure of the response you will receive from the API after the upload. This helps the platform understand and process the data returned.
Output
- Response: This variable will store the data returned by the external API after the file upload. Its structure will match the "Response format" you defined.
- Default variable name: UPLOAD_RESPONSE
- The status: This variable will contain the outcome of the file upload attempt.
- SUCCESS: The file was uploaded successfully.
- BAD_REQUEST: Your request was invalid (e.g., missing required data, incorrect format).
- UNAUTHORIZED: The provided authentication credentials were not accepted.
- NOT_FOUND: The specified endpoint URL could not be found on the remote API.
- ERROR: An unexpected error occurred during the upload process.
- Default variable name: UPLOAD_STATUS
Execution Flow
Real-Life Examples
Example 1: Uploading an Invoice to an Accounting System
Scenario: You have a new invoice PDF generated in your application and need to upload it to an external accounting system that uses an API key for authentication.
Inputs:
- Authentication method:
API Token - Token:
your_accounting_api_key_123 - Type of upload:
Form post - Headers:
\{
"X-Client-ID": "YourApp"
\} - Endpoint:
https://api.accounting-system.com/v1/invoices - Method:
POST - Query parameters: (empty)
- Request body:
\{
"invoiceNumber": "INV-2023-001",
"customerID": "CUST-456"
\} - File:
invoice_2023_001.pdf(the actual PDF file) - Response format: A data format named
InvoiceUploadResponsewith fields likeid,status,message.
Result: The invoice_2023_001.pdf file, along with its number and customer ID, is sent to the accounting system. The UPLOAD_STATUS variable will be set to "SUCCESS", and the UPLOAD_RESPONSE variable will contain the API's confirmation, such as \{"id": "INV-2023-001-UPLOAD", "status": "processed", "message": "Invoice uploaded successfully"\}.
Example 2: Updating a User's Profile Picture
Scenario: A user updates their profile picture, and you need to send the new image to a user management API that uses basic authentication.
Inputs:
- Authentication method:
Basic authentication - Username:
admin_user - Password:
secure_password_123 - Type of upload:
Binary post - Headers: (empty)
- Endpoint:
https://api.user-management.com/v2/users/\{\{current_user_id\}\}/profile-picture - Method:
PUT - Query parameters: (empty)
- Request body: (empty)
- File:
new_profile_pic.jpg(the actual image file) - Response format: A data format named
UserProfileUpdateResponsewith fields likesuccess,imageUrl.
Result: The new_profile_pic.jpg file is sent directly as binary data to update the user's profile picture. The UPLOAD_STATUS variable will be set to "SUCCESS", and the UPLOAD_RESPONSE variable might contain \{"success": true, "imageUrl": "https://cdn.user-management.com/profile_pics/\{\{current_user_id\}\}.jpg"\}.
Example 3: Submitting a Log File to a Monitoring Service
Scenario: Your application generates daily log files, and you want to automatically upload them to a monitoring service for analysis without any specific authentication.
Inputs:
- Authentication method:
None - Type of upload:
Form post - Headers:
\{
"Content-Type": "multipart/form-data"
\} - Endpoint:
https://logs.monitoring-service.com/ingest - Method:
POST - Query parameters:
\{
"source": "WebApp",
"environment": "production"
\} - Request body:
\{
"logType": "daily_activity",
"timestamp": "\{\{current_date_time\}\}"
\} - File:
activity_log_2023-10-27.txt(the actual log file) - Response format: A data format named
LogIngestionResponsewith fields likestatus,ingestionId.
Result: The activity_log_2023-10-27.txt file is uploaded to the monitoring service, along with query parameters indicating the source and environment, and body parameters for log type and timestamp. The UPLOAD_STATUS variable will be set to "SUCCESS", and UPLOAD_RESPONSE might contain \{"status": "received", "ingestionId": "LOG-INGEST-98765"\}.