Open n1k0 opened 8 years ago
I'll add a safety check but I couldn't reproduce when investigating #82 (which is likely to be the same)
The 500 is fixed with current master.
However, when running the integration tests of Kinto/kinto-http.js#115, I get a 400 because the client does not send the proper Content-Type
header: Not an HTML form submission (Content-Type: application/json)>
. It should be encode multipart, and is done automatically. Will see if I can fix there...
It should be encode multipart
Makes sense, but now I wonder how it could ever work in the kinto-admin? We definitely don't set this header there.
Also, if I force the content-type header like this:
diff --git a/src/collection.js b/src/collection.js
index a0ee33c..6ce3f86 100644
--- a/src/collection.js
+++ b/src/collection.js
@@ -193,6 +193,10 @@ export default class Collection {
const addAttachmentRequest = {
...updateRequest,
method: "POST",
+ headers: {
+ ...updateRequest.headers,
+ "Content-Type": "multipart/form-data",
+ },
body: formData
};
return this.client.execute(addAttachmentRequest, {stringify: false});
I'm getting a new server error (using latest kinto-attachment master):
ERROR:kinto.core.views.errors:"POST /v1/buckets/custom/collections/plop/records/760ce6a9-46f2-4211-a611-88da16151356/attachment" ? (? ms) Invalid boundary in multipart form: b'' agent=node-fetch/1.0 (+https://github.com/bitinn/node-fetch) authn_type=basicauth collection_id=record collection_timestamp=1468495916841 errno=110 exception=Traceback (most recent call last):
File "/home/niko/work/kinto-http.js/.venv/lib/python3.5/site-packages/pyramid/tweens.py", line 22, in excview_tween
response = handler(request)
File "/home/niko/work/kinto-http.js/.venv/lib/python3.5/site-packages/pyramid_tm/__init__.py", line 101, in tm_tween
reraise(*exc_info)
File "/home/niko/work/kinto-http.js/.venv/lib/python3.5/site-packages/pyramid_tm/compat.py", line 15, in reraise
raise value
File "/home/niko/work/kinto-http.js/.venv/lib/python3.5/site-packages/pyramid_tm/__init__.py", line 83, in tm_tween
response = handler(request)
File "/home/niko/work/kinto-http.js/.venv/lib/python3.5/site-packages/pyramid/router.py", line 158, in handle_request
view_name
File "/home/niko/work/kinto-http.js/.venv/lib/python3.5/site-packages/pyramid/view.py", line 547, in _call_view
response = view_callable(context, request)
File "/home/niko/work/kinto-http.js/.venv/lib/python3.5/site-packages/pyramid/config/views.py", line 182, in __call__
return view(context, request)
File "/home/niko/work/kinto-http.js/.venv/lib/python3.5/site-packages/pyramid/viewderivers.py", line 393, in attr_view
return view(context, request)
File "/home/niko/work/kinto-http.js/.venv/lib/python3.5/site-packages/pyramid/viewderivers.py", line 371, in predicate_wrapper
return view(context, request)
File "/home/niko/work/kinto-http.js/.venv/lib/python3.5/site-packages/pyramid/viewderivers.py", line 302, in _secured_view
return view(context, request)
File "/home/niko/work/kinto-http.js/.venv/lib/python3.5/site-packages/pyramid/viewderivers.py", line 442, in rendered_view
result = view(context, request)
File "/home/niko/work/kinto-http.js/.venv/lib/python3.5/site-packages/pyramid/viewderivers.py", line 147, in _requestonly_view
response = view(request)
File "/home/niko/work/kinto-http.js/.venv/lib/python3.5/site-packages/cornice/service.py", line 573, in wrapper
response = view_(request)
File "/home/niko/work/kinto-http.js/.venv/lib/python3.5/site-packages/kinto_attachment/views/services.py", line 17, in attachment_post
return post_attachment_view(request, SINGLE_FILE_FIELD)
File "/home/niko/work/kinto-http.js/.venv/lib/python3.5/site-packages/kinto_attachment/views/__init__.py", line 24, in post_attachment_view
content = request.POST.get(file_field)
File "/home/niko/work/kinto-http.js/.venv/lib/python3.5/site-packages/webob/request.py", line 801, in POST
encoding='utf8')
File "/usr/lib/python3.5/cgi.py", line 559, in __init__
self.read_multi(environ, keep_blank_values, strict_parsing)
File "/usr/lib/python3.5/cgi.py", line 687, in read_multi
raise ValueError('Invalid boundary in multipart form: %r' % (ib,))
ValueError: Invalid boundary in multipart form: b'' lang=None uid=a9d81e1b56f2b77103e87601621a99b3d82a15abf7c72ce57a032d0964317c7a
kinto-attachment 0.7.1, messing around with the API from js, managed to crash the server with some rotten request:
I unfortunately can't provide a curl/httpie command for reproducing as fetch doesn't expose such a feature.