-
-
Notifications
You must be signed in to change notification settings - Fork 975
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request / question: file upload helpers #195
Comments
Yes, it will be great feature |
Currently file upload support is not present. It'd be great to get a PR for this.
I actually haven't tried this (since it is a highly unlikely corner case). We use MustacheJS under the hood for interpolating variables. You can check the implementation On the syntax support for supporting file uploads, I would propose calling it as body:multipart-form {
name: photo
img: @file("example.jpg")
}
body:multipart-form {
name: photo
img: @files("example1.jpg", example2.jpg")
}
I think we should support both absolute and relative paths here. If the path is relative, then as you suggested - the it can be read relative to the to root folder of the collection. @Slijkhuis If you concur with the approach, the changes need to support this would have to be done here. The UI changes to make it a smoother ux experience would be a tad bit harder. |
I made an attempt at implementing support for this in Pull Request #258. I feel like there is probably more work to do, but the initial implementation works in the manual testing I've done locally with text and png files. |
Do you have any feedback on the DSL body:multipart-form {
name: photo
img: @file("example.jpg")
}
body:multipart-form {
name: photo
img: @files("example1.jpg", example2.jpg")
} |
For what it's worth, my implementation didn't include quotes for each path as it was additional parsing I wanted to avoid. If we want each file or path to be quoted that's a change that will have to be made. |
Until this PR gets merged. If someone is blocked, please see if fs access inside scripting can be a temporary solution |
If you are willing to get your hand's dirty, please use this script to upload files. I know it's not optimal and the best ux. I would like to take some time to think through our choice of using @ajaishankar has some DSL inputs in #344 which I am thinking through. |
We just started testing bruno, and this very feature is quite crucial for us. We had to unfortunately move to insomnia for now. I hope we see the feature coming to bruno ui soon. |
This option is essential ! |
Yes, first try on bruno and block me on file uploading with multipart form, which is widely used in REST API i think. Wish the feature is added soon. |
Another request for |
What is the current recommended approach for file upload?
Let's say there's an endpoint
POST /photos
that allows you to upload a file using amultipart-form
request. I think it would be amazing if you could do something like:Where
readCollectionFile
(just an example name) would be a built-in function to read a file relative to root folder of the collection. It could simply wrapfs.readFileSync
.Even better would be to be able to reference a file directly in the
body:multipart-form
block without requiring a script tag and setting a variable. But I'm not sure how that would look like since there can only be dictionary or text blocks right? Maybe the variable syntax could be used for a function call:The problem with setting a variable is that the UI currently shows the variables as text when you hover over the eye-icon in the right-top corner. Having image data in variables doesn't really render nicely, you won't be able to see the full variable list.
The problem with allowing function calls within the variable syntax is that when a variable is set from the response of a request, it's a security issue if then the next request might interpret the value as a function call instead of just text. I currently (= after reading the docs, I haven't read the source yet) don't understand how Bruno distinguishes between the literal string
Greeting: {{hello}}
(expected result:Greeting: {{hello}}
) and the variable substitutionGreeting: {{hello}}
(expected result:Greeting: hi
). (where variablehello
is equal tohi
). Is there any documentation about that? Maybe it could help me come up with a good syntax to reference files.Is there something for files already that I missed in the docs? If not I will try to find time to create a PR, but then I'd like some consensus on the preferred approach beforehand.
The text was updated successfully, but these errors were encountered: