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

feat: Add support for uploading files as a list #403

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vanhanit
Copy link

@vanhanit vanhanit commented 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: #401

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
Copy link
Author

vanhanit commented Oct 9, 2024

This could also be a candidate for a back-port to the 0.9 version as well.

Copy link

codecov bot commented Oct 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.79%. Comparing base (233ff7c) to head (54da020).
Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #403      +/-   ##
==========================================
+ Coverage   85.07%   88.79%   +3.72%     
==========================================
  Files           9        9              
  Lines         469      473       +4     
  Branches      117       49      -68     
==========================================
+ Hits          399      420      +21     
+ Misses         65       51      -14     
+ Partials        5        2       -3     
Flag Coverage Δ
acceptance 85.20% <100.00%> (+0.12%) ⬆️
unit 59.83% <60.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@lucagiove lucagiove left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also add a unit test to make sure files get closed for both cases list or tuple.
Thanks!

files[k].append(val)
else:
files[k] = val
for k in request.files.keys():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you also had to fix httpbin?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, as this only returned one item the way it was written. According to what I found out, you need to use the getlist(key) method to get all files for one key.

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at this point I would extract the logic to close file descriptor in a dedicated function and try to cleanup this part

@lucagiove lucagiove linked an issue Oct 25, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Files param doesn't have to be a dictionary type
2 participants