usebruno / bruno

Opensource IDE For Exploring and Testing Api's (lightweight alternative to postman/insomnia)
https://www.usebruno.com/
MIT License
25.27k stars 1.15k forks source link

Generating curl snippet for file in multi-part: missing @ #2224

Open fskexp opened 4 months ago

fskexp commented 4 months ago

I have checked the following:

Describe the bug

.bru file to reproduce the bug

meta {
  name: post-with-file
  type: http
  seq: 2
}

post {
  url: https://server.com/
  body: multipartForm
  auth: none
}

body:multipart-form {
  file-param: @file(/private/tmp/data.txt)
}

Screenshots/Live demo link

Without the @ (current behaviour), the request (as intercepted by a proxy) will contain the path of the file

--------------------------PkQw3TWuFyPky39PXxv28K
Content-Disposition: form-data; name="file-param"

/tmp/data.txt
--------------------------PkQw3TWuFyPky39PXxv28K--

If a @ is manually added, then the content of the file is sent:

--------------------------yHQvrEAijwpPonqPCwZZ8H
Content-Disposition: form-data; name="file-param"; filename="data.txt"
Content-Type: text/plain

coucou

--------------------------yHQvrEAijwpPonqPCwZZ8H--
leoferreiralima commented 4 months ago

@fskexp i have submited a solution on a PR to this, if you can review maybe can be merged soon

Fabiensk commented 4 months ago

Hi, it looks good for me. I verified that in the httpsnippets library the @ is added if the parameter is ‘fileName‘

leoferreiralima commented 4 months ago

@Fabiensk exactly, I have added this rule on my PR, can you review please?