alexandrehtrb / Pororoca

An HTTP inspection tool with support for HTTP/2 and HTTP/3. Alternative to Postman.

Home Page:https://pororoca.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request - plugins / encoding arbitrary file as base64

SoftExpert opened this issue · comments

Hello,

While using Insomnia I was able to adapt a plugin that allowed me to load and use an arbitrary file as a Base64 encoded string inside the body of the request (as a value of a JSON attribute).

A screenshot of the original configuration:
image

Here is a screenshot with the macro "loaded" with a file
image

And here is a screenshot with its configuration interface in Insomnia
image

It seems today there is no possibility to do that, so I'm wondering if there is a way to either implement it as a native feature or, at least, allow to add it through a plugin mechanism.

Thank you in advance for your help on this feature !

Best regards
SoftExpert

Edited to add more screenshots

Hello @SoftExpert ,

This feature is possible to be done, however, there are alternative ways to handle this case that are better in my opinion.

When binary data is encoded into Base64, its size is increased roughly in 33% and there is a processing time for the conversion.

Instead of sending a file as a Base64 string inside a JSON, you can:

  1. Use a Multipart Form Data request body, with one part being the binary file, the PDF in your example, and another part being the metadata;

  2. Use a File request body to send your file and include metadata in request headers;

  3. Have two separate requests, one to send your file in binary, and another to send metadata.

Hi Alexandre,

I'm not searching for a better way to submit a file; I have to use an existing API which requires me to send the file encoded in Base64 as the value of a specific attribute.

The ugly "solution" would be to just put the huge JSON in the body and then use it like this; the more elegant way is to either have a variable / macro or an extension that allows to search and produce the Base64 content at the moment of the request.

The possibility exists in Insomnia through an extension (used in the screenshots).
I find the feature very interesting because when the collection is exported the resulting file is not heavy - only the path of the file is referred.

With this feature available I would be able to completely replace Postman / Insomnia ...

I think that a plugin system would be really powerful and allow for very quirky situations to be easily solved.

Best regards,
SoftExpert

Sorry, @SoftExpert , but this use case is not common enough to be added as a feature, so I will close and mark this as not planned.

A plug-in system could exist, but is not planned in a near future.