Skip to content

Attach binary files to requests #13

@danirod

Description

@danirod

Currently there is no way to do this. There are two tasks for this are closely related, so they both should be added.

Loading a raw body from a file

A new body type is added to the dropdown:

A screenshot of how the UI of Cartero would look like if the Body type dropdown in the request body tab had an extra option that says From File

When this option is picked, the pane details expand to a file picker and a text input to set the content-type (application/octet-stream by default; but you can change it if you want.)

At the data model, this is another body type. This is not the same as a raw request.

When the request is submitted, the contents of the file are read, and these are attached just like they would be sent in a request with raw body.

When the request is saved, the type is set to "file" and the path to the actual file is included in the .cartero file:

[body]
type = "file"
file = "assets/banner.jpg"
type = "image/jpeg"

Attaching files to multipart requests

Multipart requests allow mixing inline text parts with file parts. A "Add field" button should be added below the table, that allows to attach extra files to the multipart body.

The file is rendered in the table, so that you can see the file name, and disable it if you want. But the field is not editable. The ··· button might present a way to "open" the file, as in "open this image or file with the default application in your computer to open these files".

A screenshot of how the UI of Cartero would look like with an Add file button added below the params table in a multipart request. There is a button that says Add file, and one of the rows has the value set to something that looks like a file path

(This is just a mock, don't consider this final.)

When the request is sent, the contents of the file are added to the request. The content-type, if available, is passed through.

When serialized to a file, a new sub-table for the files attached to a multipart request is added with the path to each file.

[body]
type = "multipart"

[body.variables]
user = "admin@example.com"
password = "1234"

[body.files]
avatar = "file.jpg"
id_card = { value = "fixtures/id_card.png", active = false }

Metadata

Metadata

Assignees

Labels

Next versionScheduled for the next version

Projects

Status

In Progress

Relationships

None yet

Development

No branches or pull requests

Issue actions