Ask AI
Skip to main content

Upload file

Function: Upload file

Effortlessly connect and upload a file to external APIs, simplifying data integration and enhancing the functionality of your applications through a user-friendly, code-free interface. This action allows you to send files to a specified web address (endpoint) using various authentication and upload methods.

Input

  • Authentication method (SELECT_ONE, Required, Default: None) Specify how you want to securely connect to the API.
    • Basic authentication: Use a username and password.
    • Bearer Token: Use a token for authentication.
    • Api Token: Use an API key for authentication.
    • None: No authentication will be used.
  • Username (STRING) If you chose "Basic authentication", provide the username for access.
  • Password (PASSWORD) If you chose "Basic authentication", provide the password for access.
  • Token (PASSWORD) If you chose "Bearer Token" or "API Token", provide the token or API key for access.
  • Type of upload (SELECT_ONE, Required, Default: Form post) Choose how the file should be sent to the API.
    • Form post: Uploads the file as part of a web form (multipart/form-data).
    • Binary post: Uploads the file directly as raw binary data.
  • Headers (OBJECT) Define any custom headers (key-value pairs) that need to be included in the API call, such as content type or custom authorization.
  • Endpoint (STRING, Required) The full web address (URL) where the file will be uploaded.
  • Method (SELECT_ONE, Required, Default: POST) Choose the HTTP method for the upload.
    • PUT: Used to update an existing resource or create one if it doesn't exist.
    • POST: Used to create a new resource.
  • Query parameters (OBJECT) Specify additional parameters (key-value pairs) that will be appended to the endpoint URL.
  • Request body (OBJECT) Provide additional data (key-value pairs) to be sent along with the file, especially when using "Form post" upload type.
  • File (FILE, Required) The actual file you want to upload.
  • Response format (DATA_FORMAT, Required) Define the expected structure of the data that the API will send back after the upload. This helps the platform understand and process the response.

Output

  • Response (OBJECT, Default: UPLOAD_RESPONSE) The data returned by the API after a successful upload, structured according to the specified Response format.
  • The status (STATUS, Default: UPLOAD_STATUS) A variable that will contain the outcome of the upload attempt. Possible values include:
    • SUCCESS: The file was uploaded successfully.
    • BAD_REQUEST: The request sent to the API was invalid.
    • UNAUTHORIZED: The provided authentication credentials were not accepted.
    • NOT_FOUND: The specified endpoint could not be reached on the remote API.
    • ERROR: An unexpected error occurred during the upload.

Execution Flow

Real-Life Examples

Example 1: Uploading a Product Image to an E-commerce API

Imagine you're managing an online store and want to upload a new product image to your e-commerce platform's API.

  • Inputs:
    • Authentication method: API Token
    • Token: your_api_key_12345
    • Type of upload: Form post
    • Headers: \{"Accept": "application/json"\}
    • Endpoint: https://api.example.com/products/123/images
    • Method: POST
    • Request body: \{"alt_text": "Blue T-shirt", "is_thumbnail": true\}
    • File: product_image.jpg (a file selected from your application)
    • Response format: A data format named ProductImageResponse that defines fields like id, url, status.
    • Response: NewImageDetails
    • The status: ImageUploadStatus
  • Result: The product_image.jpg is uploaded to the e-commerce API. The ImageUploadStatus variable will be set to SUCCESS, and the NewImageDetails variable will contain the API's response, such as \{"id": "img_001", "url": "https://cdn.example.com/img_001.jpg", "status": "uploaded"\}.

Example 2: Updating a Document in a Cloud Storage Service

You need to replace an existing document in a cloud storage service via its API.

  • Inputs:
    • Authentication method: Bearer Token
    • Token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9... (your JWT token)
    • Type of upload: Binary post
    • Headers: \{"Content-Type": "application/pdf"\}
    • Endpoint: https://api.cloudstorage.com/documents/report_q4_2023.pdf
    • Method: PUT
    • File: updated_report_q4_2023.pdf (the new version of the file)
    • Response format: A data format named DocumentUpdateResponse with fields like filename, size, lastModified.
    • Response: UpdatedDocumentInfo
    • The status: DocumentUploadStatus
  • Result: The updated_report_q4_2023.pdf replaces the old document on the cloud storage. The DocumentUploadStatus variable will be SUCCESS, and UpdatedDocumentInfo will hold details like \{"filename": "report_q4_2023.pdf", "size": 123456, "lastModified": "2023-10-27T10:00:00Z"\}.

Example 3: Submitting a User Profile Picture to a Social Media Platform

A user wants to upload a new profile picture to their social media account.

  • Inputs:
    • Authentication method: Basic authentication
    • Username: [email protected]
    • Password: securePassword123
    • Type of upload: Form post
    • Endpoint: https://api.socialmedia.com/users/me/profile-picture
    • Method: POST
    • Query parameters: \{"quality": "high"\}
    • File: profile_pic.png
    • Response format: A data format named ProfilePictureResponse with fields like profileImageUrl, thumbnailUrl.
    • Response: ProfilePictureData
    • The status: ProfilePictureUploadStatus
  • Result: The profile_pic.png is uploaded as the user's new profile picture. The ProfilePictureUploadStatus variable will be SUCCESS, and ProfilePictureData will contain the URLs to the new image, for example, \{"profileImageUrl": "https://cdn.socialmedia.com/user123/profile.png", "thumbnailUrl": "https://cdn.socialmedia.com/user123/thumb.png"\}. If the username or password was incorrect, ProfilePictureUploadStatus would be UNAUTHORIZED.