You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I used a generator as an argument to data for Content-Type application/json, and that worked fine.
The problem now is that I need to do this for multipart/form-data, and it appears to not support a generator.
I tried files={'content': my_generator_func()} and got: a bytes-like object is required, not 'generator'; so it looks like it would have accepted a file descriptor, but not a generator.
I then tried a generator for the data argument, and set the files argument to a form name and value: files={'encoding': (None, 'base64')} [I read you have to use the files argument to get requests to do multipart/form-data] For that I get the error "Streamed bodies and files are mutually exclusive".
Just in case, I tried it different ways setting a header for Content-Type multipart/form-data, both with and without it [I had read that setting it yourself can mess up requests.] If I omitted it, it complained it was missing; and if I included it, I got the errors previously specified.
Is it possible to furnish a generator for multipart/form-data? If I have to, I will dump the stream into a file and pass a descriptor to the files argument; but seems that you would have furnished a way to use a generator since it is supported for Content-Type application/json
The text was updated successfully, but these errors were encountered:
I used a generator as an argument to data for Content-Type application/json, and that worked fine.
The problem now is that I need to do this for multipart/form-data, and it appears to not support a generator.
I tried files={'content': my_generator_func()} and got: a bytes-like object is required, not 'generator'; so it looks like it would have accepted a file descriptor, but not a generator.
I then tried a generator for the data argument, and set the files argument to a form name and value: files={'encoding': (None, 'base64')} [I read you have to use the files argument to get requests to do multipart/form-data] For that I get the error "Streamed bodies and files are mutually exclusive".
Just in case, I tried it different ways setting a header for Content-Type multipart/form-data, both with and without it [I had read that setting it yourself can mess up requests.] If I omitted it, it complained it was missing; and if I included it, I got the errors previously specified.
Is it possible to furnish a generator for multipart/form-data? If I have to, I will dump the stream into a file and pass a descriptor to the files argument; but seems that you would have furnished a way to use a generator since it is supported for Content-Type application/json
The text was updated successfully, but these errors were encountered: