Locoia
  • Overview
  • Account and User Settings
    • User types
    • Adding Users
    • Teams
    • Access Permissions
    • 2 Factor Authentication 2FA
    • Versioning and Snapshots
    • Activity Log
  • Reset your Password
  • Invoices and Payments
  • Automation
    • Flow Builder
      • Flow Building Best Practices
      • Jinja Template Language
        • Jinja: (Custom) variables, wildcards and functions
        • Magic Code Samples
      • Connectors & APIs
        • Titles and References
        • Referencing data of objects, lists, arrays - how to pass data dynamically
        • Accessing Objects with JSONPath
        • Merging nested JSON objects
        • Parsing JSONs from String
        • Response Headers & Status Codes
        • Custom Data Fields
        • Wildcard API calls and actions
        • Response cleaning
      • Text Strings, Date & Time, Numbers and Currencies
        • Text and Strings
        • Dates & Time
        • Numbers (Thousand Separators, Currencies)
      • Email-formatting
      • Code Fields
      • Running single Flow steps
      • Flow run data retention, logging, and error notifications
      • Advanced View
      • Dynamic Title
      • Custom Error Handling
      • Error Handling Flows
      • Automatic Pagination
    • Flow Debugger
      • Automatic Retrying
      • Run Flows again
      • Troubleshooting Flows
    • Community Library
  • Connectors & Helpers
    • Connectors
      • Monday.com
      • ActiveCampaign
      • Aircall
      • Allthings
      • Amplitude
      • Animus
      • Assetti
      • Awork
      • AWS RDS Database - How to connect
      • bubble.io
      • Casavi
      • Chargebee
      • CleverReach
      • comgy
      • commercetools
      • Everreal
      • Exact Online
      • Facebook Marketing
      • Fahrländer Partner
      • FastBill
      • FILESTAGE.io
      • Freshdesk
      • Freshsales
      • Google Ads
      • Google Ads Lead Form
      • Google Analytics
      • Google Chat
      • Google Drive
      • Google Sheets
      • Gmail
      • HubSpot
      • Heyflow
      • iDWELL
      • ImmobilienScout24
      • Instagram Ads
      • Intercom
      • klaviyo
      • Kiwi Opening Doors
      • Klenty
      • Klipfolio
      • Kolibri CRM
      • konfipay
      • KUGU
      • Shopify
      • S3 AWS
      • SQS AWS
      • Lambda AWS
      • Learnster
      • lexoffice
      • LineMetrics
      • Linkedin
      • Locoia
      • Notion
      • MailGun
      • Makula
      • Microsoft Dynamics 365
      • Microsoft OneDrive
      • MixPanel
      • MongoDB
      • Odoo
      • OnFleet
      • OnOffice
      • Oracle NetSuite
      • Outbrain
      • Quickbooks
      • Trello
      • PandaDoc
      • Personio
      • Pinterest Ads
      • Pipedrive
      • Plentific
      • PriceHubble
      • relay
      • REALCUBE
      • Sage ERP
      • Salesforce
      • SAP
      • Scoro
      • Seafile
      • sevDesk
      • SharePoint
      • SharpSpring
      • Slack
      • Snapchat Marketing
      • Snowflake
      • Teamleader Focus
      • Teamwork.com
      • Tableau
      • TikTok
      • TinQwise
      • The Trade Desk
      • Twitter
      • Typeform
      • WordPress
      • Xero
      • Youtube
      • Zendesk
      • Zoho CRM
      • Zoom
    • Helpers
      • Scheduler
      • Webhook
      • Dict Helper
      • Spreadsheet Helper
      • REST Helper
      • Boolean Helper
      • Multi Case Helper
      • Looper
      • FTP Helper
      • CSV Helper
      • XLSX Helper
      • Mail Sender
      • Flow Trigger
      • File Storage Helper
      • Terminate Helper
      • Delay Helper
      • SQL Connector
      • PDF Helper
      • Zip Helper
      • Data Warehouse Helper
      • XML Helper
      • Form Helper
      • Arrow
      • Error Arrow
    • Authentication Types Available
      • Setting up authentication
      • OAuth1
      • OAuth2
      • Refreshable token
      • AWS Signature
      • Basic Auth and Other Simple Authentication Methods
      • How are API versioning and API updates handeled?
      • Custom OAuth2 clients (apps)
    • Building Connectors
      • Base Connector Setup
        • Connector Auth Validation
        • GraphQL APIs
        • Rendering with User Input
      • Building Connector Actions
        • Actions Examples
      • Search Automation
      • Pagination Automation
      • Uploading Files in Actions
      • Working with SOAP APIs
    • Super Actions
    • Webhook Trigger for Connectors
    • Data Mapping and Env Variables
  • Embed - White Label Portal
    • Embed Overview
      • 1. Embed Flow
        • 1.1 Creating Embed Flows
        • 1.2 Updating Embed Flows
        • 1.3 Embed Error Handling
        • 1.4 Setting up Callbacks for Integration activation/deactivation
        • 1.5 Setting up Remote search
        • 1.6 Setting up End User logs
      • 2. Configure Embed
        • 2.1 Embed Integration via SSO
        • 2.2 Proprietary connector setup
        • 2.3 Sharing level
        • 2.4 Consent screen
        • 2.5 Account Secrets
        • 2.7 Further settings
      • 3. Integrate Embed
        • 3.1 iframe vs native embed
        • 3.2 Customizing CSS
        • 3.3 Events emitted from iframe to parent window
      • 4. Embed for End User
        • 4.1 Embed Remote Search
        • 4.2 Embed End User Logs
      • 5. Test Embed Configuration
        • Testing example
      • 6. Embed Integrations and Connector Auths
    • Embed FAQs
  • Data and Dashboards
    • Dashboards & Insights
      • Introduction to Dashboards
      • Introduction to Insights
      • Introduction to Data Sources
      • Dashboard Filters
      • Insight Marketplace - Using Pre-Built Insights
      • Writing SQL Queries
      • Useful SQL Examples
      • Charts
        • Line Chart
        • Bar and Horizontal Bar Chart
        • Stat Card
        • Pie Chart
        • Gauge Chart
        • Donut Chart
        • Stacked Bar, Horizontal Stacked Bar, and Normalized Horizontal Stacked Bar
        • Multiple Line Chart
        • Pivot Table
        • Map Chart
  • Best Practice Guides
    • Integration Best Practices
    • Integration Check List
    • CSV Files in Excel
    • Multi-Tenant Flows
    • On-Premise Integrations
    • Database Connection Setup
    • Data and General Security
    • Using Tags
    • FAQ
  • API
    • Locoia API Authentication - Personal Access Token
    • Create Connector Authentication
  • Contact us
  • Status of Service
  • Data Privacy
  • Imprint
Powered by GitBook
On this page
  • General
  • Body parameters
  • File meta data
  • Alternative Content-Type header
  • Additional parameters
  • form_item_name
  • upload
  • Upload as base64 string
  • Uploading files using REST Helper

Was this helpful?

  1. Connectors & Helpers
  2. Building Connectors

Uploading Files in Actions

Here is everything you need to know to configure action so that they can upload files.

PreviousPagination AutomationNextWorking with SOAP APIs

Last updated 1 year ago

Was this helpful?

General

In order to upload files through an action, either a public URL or a URL that is available in a Flow (e.g. the output of the ) needs to be referenced to in a field with the key request_binary_url, which can be configured like this in the :

{
  "request_binary_url": {
    "title": "File URL where the file is fetched from",
    "type": "text",
    "required": false,
    "info": "The file can come from a previous step of a Locoia flow or from a static location on the web"
  }
}

Only the key (request_binary_url) needs to be exactly as in the example, all other parameters can be set according to the action.

If that key is set and a valid URL is passed to it, the file will be converted to binary format and sent with the header value "Content-Type": "multipart/form-data".

The body consists of

  • name which is by default file,

  • filename which is based on the file name in the URL or if that cannot be retrieved file,

  • Content-Type which is based on the file itself, and

  • the file itself in binary format

and looks like this (without the file):

Content-Disposition: form-data; name="file"; filename="example-image.png".
Content-Type: image/png.

If the endpoint expects the file to be uploaded in that way, both the Request Body and Header Template need to be configured with {} only.

Body parameters

These parameters will then have the filename parameter, equal to the name of the Parameter. In case that is not desired or accepted by the API, the header should be set to:

{
  "Content-Type": "multipart/form-data"
}

File meta data

The following file meta data can be used in the body or header by referencing to binary_file.

  • name

  • content

  • mime_type

Alternative Content-Type header

To use a different Content-Type than the standard multipart/form-data, the Request Body Template needs to be left empty and the Content-Type that should be used needs to be set in the Request Header Template.

Additional parameters

form_item_name

  {
  "request_binary_url": {
    ...,
    "form_item_name": "image"
  }
}

upload

{% set boundary = str(uuid(4)) %}
{% set raw = [
  'Content-Type: multipart/mixed; boundary="' + boundary + '"\n',
  'To: <' + to_email + '>\n',
  ...,
  '--' + boundary + '\n',
  'Content-Type: text/' + body_type + '; charset="UTF-8"\n\n',
  body,
] %}
{% if binary_file != None %}
  {% set raw = raw + [
    '\n\n--' + boundary + '\n',
    'Content-Type: ' + binary_file.mime_type + '; name="' + binary_file.name + '"\n',
    'Content-Disposition: attachment; filename="' + binary_file.name + '"\n',
    'Content-Transfer-Encoding: base64\n\n',
    binary_file.content | base64_encode
  ] %}
{% endif %}
{% set raw = raw + ['\n\n--' + boundary + '--'] %}
{
  "raw": "{{ raw | join | base64_encode("urlsafe") }}"
}

Upload as base64 string

Some Connectors expect files as base64 strings. In order to upload files like this, the upload parameter needs to be used.

So the Action setup would look something like this:

UI Form Schema
{
  "request_binary_url": {
    "title": "File URL where the file is fetched from",
    "type": "text",
    "required": false,
    "upload": false,
    "info": "The file can come from a previous step of a Locoia flow or from a static location on the web"
  }
}
Request Body Template
{
  "some_field_name": "{{ binary_file.content | base64_encode }}"
}

Uploading files using REST Helper

You can also upload a file using REST Helper.

  1. Specify the API URL:

    • Determine the appropriate API endpoint you want to interact with.

  2. Set Authorization Header:

    • Optional, if required by the API

  3. Select Content Type:

    • If you want to upload a file, you should select

    multipart/form-data

  4. Set empty Body

    {}

  5. File to Upload

    {{ some_pdf }}

In addition to the automatically set body key-value pair, additional ones can be sent (which is e.g. required by ), by adding the parameters to the body like regular parameters. These will then be sent as form-data as well.

For an example usage, .

If the Request Header Template is left empty, no Content-Type header will be sent. This is e.g. needed for (and other Microsoft file upload endpoints.

Some APIs, such as require that the name in the body is set to something else than the default file, in that case image. This can be configured directly in the UI Form Schema, by specifying the parameter form_item_name with the name that should be sent, e.g.:

This parameter can be set to false if the file should not actually be uploaded, but only be converted to binary format and then uploaded in another format. This is for example needed to , where the request body needs to be built in the request body template and then base64 encoded:

HubSpot
SharePoint file upload
this one
send emails with attachments with Gmail
see the Gmail action
More details
CSV Helper
UI Form Schema Renderer