Skip to content
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

Files param doesn't have to be a dictionary type #401

Closed
patrikwilliam opened this issue Sep 13, 2024 · 2 comments · Fixed by #403
Closed

Files param doesn't have to be a dictionary type #401

patrikwilliam opened this issue Sep 13, 2024 · 2 comments · Fixed by #403
Assignees
Milestone

Comments

@patrikwilliam
Copy link

is_file_descriptor, list(files.values()) + [data]

It seems that a new change was introduced and now all the files used for POST have to be in the specific format.

However, this is not the case for all the scenarios. One can use Py requests to upload multiple files using list of tuples.

E. g.
multiple_files = [
('images', ('foo.png', open('foo.png', 'rb'), 'image/png')),
('images', ('bar.png', open('bar.png', 'rb'), 'image/png'))]

This no longer works and would be great to be fixed to be in align with Py requests library.

This causes the 'list' object has no attribute 'values' error. The workaround is to use the dictionary structure, but problem is if you need multiple files uploaded with same 'file' tag. Dictionary has to have unique key, having 4 times 'file' as the key is not possible.

@patrikwilliam patrikwilliam changed the title Files param doesn't have to be a list Files param doesn't have to be a list of dictionaries Sep 13, 2024
@patrikwilliam patrikwilliam changed the title Files param doesn't have to be a list of dictionaries Files param doesn't have to be a list with a dictionary type Sep 13, 2024
@patrikwilliam patrikwilliam changed the title Files param doesn't have to be a list with a dictionary type Files param doesn't have to be a dictionary type Sep 13, 2024
@lucagiove
Copy link
Member

when you talk about new change is in original requests library? could you provide more references to the changelog or documentation and the version you noticed this?

vanhanit pushed a commit to vanhanit/robotframework-requests that referenced this issue Oct 9, 2024
Uploading a list of files with the same key is supported by the Requests library.
This allows the receiving server to accept a list of files for the same key, i.e. accepting an arbitrary number of files.
Issue: MarketSquare#401
vanhanit pushed a commit to vanhanit/robotframework-requests that referenced this issue Oct 9, 2024
Uploading a list of files with the same key is supported by the Requests library.
This allows the receiving server to accept a list of files for the same key, i.e. accepting any number of files.
Issue: MarketSquare#401
@patrikwilliam
Copy link
Author

Hi @lucagiove thanks for a follow-up, it was broken by changes in commit 4de7ccd:
4de7ccd#diff-1a10b1ae09ff166af95b8df428f6c301eb3ab7357d207b8ded10eb09e93926de on Apr 8 which should have fixed the closing of files, though it brought this regression up.

Thanks @vanhanit for having the PR ready, it works fine if that matters, maybe @lucagiove can give you a code review unless there are other proposals to have this fixed?

@lucagiove lucagiove self-assigned this Oct 25, 2024
@lucagiove lucagiove added this to the 1.0 milestone Oct 25, 2024
@lucagiove lucagiove linked a pull request Oct 25, 2024 that will close this issue
vanhanit added a commit to vanhanit/robotframework-requests that referenced this issue Oct 30, 2024
Uploading a list of files with the same key is supported by the Requests library.
This allows the receiving server to accept a list of files for the same key, i.e. accepting any number of files.
Issue: MarketSquare#401
vanhanit added a commit to vanhanit/robotframework-requests that referenced this issue Oct 30, 2024
Uploading a list of files with the same key is supported by the Requests library.
This allows the receiving server to accept a list of files for the same key, i.e. accepting any number of files.
Issue: MarketSquare#401
lucagiove pushed a commit that referenced this issue Nov 4, 2024
Uploading a list of files with the same key is supported by the Requests library.
This allows the receiving server to accept a list of files for the same key, i.e. accepting any number of files.
Issue: #401
@github-project-automation github-project-automation bot moved this from To do to Done in Next Version Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants