-
-
Notifications
You must be signed in to change notification settings - Fork 190
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
YAML syntax prevents uploading multiple files with the same "name" #833
Comments
Proposed syntax change to allow this: request:
url: '{url}'
method: POST
files:
# Send file_1.txt and file_2.txt, both with name="input_files", in the multipart data.
input_files:
- 'file_1.txt'
- 'file_2.txt' With the long style looking like this: request:
url: '{url}'
method: POST
files:
# Send file_1.txt and file_2.txt, both with name="input_files", in the multipart data.
input_files:
- file_path: "file_1.txt"
content_type: "application/customtype"
content_encoding: "UTF16"
- file_path: "file_2.txt"
content_type: "application/customtype"
content_encoding: "UTF16" The current scalar syntax could still be supported for backwards compatibility. I think it would be equivalent to a list with 1 element. [EDIT] This syntax might be flawed because it can't preserve order. See #833 (comment) for an update. |
I don't think this would be a huge amount of work, just updating the jsonschema and the file parsing in the rest request code |
@michaelboulton If it's helpful, I can take a shot at implementing this over this weekend or the next. |
Hi @michaelboulton @SyntaxColoring any update on the above? Let me know if I can help. |
@debugger24 I've cloned the repo to start on this, but I ran into some mysterious Docker-related errors that I haven't had a chance to debug. If you want to give it a whirl, I won't complain. :) Otherwise, I'll get to it eventually. I've also realized that my initially proposed syntax is a bit flawed. Instead of this, which I initially proposed: request:
url: '{url}'
method: POST
files:
# Send file_1.txt and file_2.txt, both with name="input_files", in the multipart data.
input_files:
- file_path: "file_1.txt"
content_type: "application/customtype"
content_encoding: "UTF16"
- file_path: "file_2.txt"
content_type: "application/customtype"
content_encoding: "UTF16" I now think it should be this: request:
url: '{url}'
method: POST
files:
# Send file_1.txt and file_2.txt, both with name="input_files", in the multipart data.
- field_name: "input_files"
file_path: "file_1.txt"
content_type: "application/customtype"
content_encoding: "UTF16"
- field_name: "input_files"
file_path: "file_2.txt"
content_type: "application/customtype"
content_encoding: "UTF16" Because the ordering of parts in a multipart upload can be significant, apparenly. |
Can you see whether #870 solves your problem? I've added some tests to it but it would be good to get some third party confirmation |
It looks like Tavern's current YAML syntax prevents using Tavern for certain standard kinds of multi-file uploads.
If you have an HTML form input like this:
Then the
POST
request should look like this:Notice how both files have
name="input_files"
, even though they have differentfilename
s and different contents.Quoting from RFC 7578 section 4.3:
In
requests
, you can do this by providing a list as thefiles
argument:But in Tavern's YAML syntax, this doesn't seem possible.
The text was updated successfully, but these errors were encountered: