-
Notifications
You must be signed in to change notification settings - Fork 435
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
Upload list of files as single element in multipart body #390
Comments
would it be possible for you to elaborate on this issue, if you can give me a clearer understanding of what you want I will make a branch and see if I can add the functionality you are after. I am sorry to say I think I fully understand the problem. if you could provide as much detail as you can I will do my best to implement this |
@markGilchrist Given a list of files named foo, instead of having one datapart per file (named foo1 foo2 foo3), they want one datapart in total named foo with all the files. |
* Fix download to memory ( #414) * Fix logging a consumed body Just ensures the request can STILL be logged, even after the body is consumed (written to an output). * Fix coroutines and remove redundant charset parameter * Fix empty issues When there was not last item, this call would fill. LastOrNull fixes that but this should only return on null items. * Add generic readers and writers for everything that is a body. * Add a few more headers * Add KDoc for Body interface * Add typealias for progress * Add test for DefaultBody * Add empty test * Add Content-Encoding and Transfer-Encoding tests * Add helper for mocking reflection * Add HttpClientTest * Add test to confirm #464 is possible * Add test for issue (#473) * Add test for issue (#408) * Add test for issue (#364) * Add Body for Response This actually makes sure response bodies are treated like request bodies and not read multiple times. This also makes the streams completely lazy (as they are wrapped in an anonymous function). * Add a warning about non-utf8 charset for bodies * Add type aliases * Add lazy length for bodies * Add special "lazy body" and don't call input streams twice This switches to use a UploadBody data class that determines its length at most once, and writes directly to the output stream. This is actually prework for #479 #399 and #390 #344. * Add use caches option to client and request By default, HTTPUrlConnection supports caching, but this was always turned off. This enables it by default, but allows for a "browser refresh" by passing in an argument. * Add TE/Transfer-Encoding to HttpClient * Add explanatory comments to HttpClient * Add request flag to stop decoding content This can be used if for example you want to download some content as gzipped and store it directly. * Change (simplify) non-null invokes * Change classes to data classes for easy copy * Change condition to have common path first * Change body to be an interface This allows us to actually define different type of bodies, as well as extending a body to support #464. The length is now also a lazy call, so that it may be calculated ONLY if necessary. * Change default name of files to "file" The empty filename with _1 looks disturbing. * Change automatic determination of a file's length to only match the encoded length, if it's going to be written with UTF-8. * Change response method types (cleanup) * Change argument naming * Change input stream to be buffered * Change to return instantly if empty * Change default bodies to be consumable at most once This solves multiple issues with input streams being read twice, when logging is turned on. Before, toByteArray would load into memory and that was that. Now it reads directly from an inputstream. However, most streams are only consumable once, thus this solves that. When the stream is read into memory we might as well keep it around. * Change upload body to be writable at most once See the commentary for the DefaultBody * Change the client for the new body api * 📖 Change and format README with new API * Remove redundant braces * Remove bash dollar sign The bash dollar sign only indicates that a string is a command and not a result. It should not be part of the actual string returned, as the string returned can not be forwarded to a system call. * Remove debugging println * Remove debug logging * Remove TODO The logingResponseLogger logged both request and response. Now it correctly only logs the response, and expects you to log the request using a request interceptor. This also makes the logs not show up next to each other, but when they are executed, allowing us to debug async requests. * Remove default ACCEPT_ENCODING Accept-Encoding is to accept content with a certain Content-Encoding, for example when request a file, you may ask for it gziped. However, it is not intended to be used as the encoding of the stream, also known as Transfer-Encoding. * Remove deprecated fields
Based on RFC7578: https://tools.ietf.org/html/rfc7578 This is a breaking change, but mostly deprecates current functions as error. Removes all the extranous methods and bookkeeping from UploadRequest and UploadBody, and delegates those to the DataPart. This also allows for InlineDataPart that yield a file on the server and removes automatic naming for dataparts (_1, _2), because the correct way to put multiple files under the same name is to give them... the same name! Fixes #344 Fixes #390 Fixes #399 Fixes #479 Fixes #513
* Overhaul upload requests, Blob and DataPart Based on RFC7578: https://tools.ietf.org/html/rfc7578 This is a breaking change, but mostly deprecates current functions as error. Removes all the extranous methods and bookkeeping from UploadRequest and UploadBody, and delegates those to the DataPart. This also allows for InlineDataPart that yield a file on the server and removes automatic naming for dataparts (_1, _2), because the correct way to put multiple files under the same name is to give them... the same name! Fixes #344 Fixes #390 Fixes #399 Fixes #479 Fixes #513 * Add kdocs * Tests, docs and rock & roll * Remove debug information * Use new API * Add convenience methods * 💅 Clean up warnings
See the issue #169, which seams try to get the same, but was closed before somebody give the solution.
I tried solution in that issue, but the resulting multipart body still contains separate part for each file. The name of the parts are "files1", "files2", etc.
What I need (and seams the originator of that topic) the multipart with single part named "files" and containing the list of files.
How can we do THAT?
The text was updated successfully, but these errors were encountered: