Automate

Automate

Make your phone or tablet smarter with automation

Get it on Google Play

File multipart extract

A decision block extracts a part for an multipart encode file.

The fiber will pause until the part has been extracted, proceeding through the YES path if the specified part was present, or through the NO if not.

This can be used to read content from an multipart/* encoded request or response body saved as a file, e.g. an multipart/form-data request received by the HTTP accept block.

An boundary mark is required, it’s usually obtained from an "Content-Type" request header, e.g. using the matches function like so matches(headers["Content-Type"], ".*;\\s*boundary=(['\\\"]?)([^;]+)\\1.*")[2].

If the part name is omitted then the part at index is extracted, otherwise the index:th part with the name is extracted, for cases where multiple parts have the same name.

The save part controls if, and how the part content will be saved. If Save to file, then the path can be set to an existing or new file, or to a directory where the file will be placed with an automatic name. The path to the actual file extract is assigned to the part content variable.

Input arguments

  • File — path to multipart file.
  • Boundary mark — mark delimiting each part.
  • Part name — name of form-data part to extract, default is any.
  • Part index — index of part to extract, default is 0 (zero).
  • Save part — how to save part content, default is Don’t save.
  • Part content path — file or directory path where the extract part content will be saved, default is a file in the “Download” directory.

Output variables

  • Part content — variable to assign the part content as text, or path to received file.
  • Part headers — variable to assign a dictionary with the part headers.
Note! This documentation is also accessible within the app from Help & feedback menu.