3

I have seen documententaion here:

http://docs.marklogic.com/guide/rest-dev/bulk#id_54649

It starts with " To write multiple documents in a single request, send a POST request to the /v1/documents service with a URL of the following form and set the Content-Type header to multipart/mixed. "

Problem is I use python Requests that, by default, uses content-type multipart/form-data which I cannot change see other SO question

So my question: can I set up Marklogic REST extension so it uses multipart/form-data instead of multipart/mixed

2 Answers 2

1

XQRS can accept file uploads via multipart/form-data requests no sweat, including multiple uploads of course. It's also a great and simple way of making RESTful Web Services on MarkLogic. Check it out.

0

As detailed in the python SO question you are referring to, there are libraries that should allow you to compose a true multipart/mixed request to use against /v1/documents.

Having said that, I think it should be real easy to support multipart/form-data from anywhere inside MarkLogic. It is supported natively, and from the looks of it REST extensions can work with them too.

I ran a quick test with an HTML upload form that uses method="post" enctype="multipart/form-data". Inside the form you can use input field of type file. Regarding REST extensions, just make sure you prefix any input field name with rs: as required for custom params to REST extensions. And if you want to insert the files into the database, you will need to annotate the REST extension post function with %rapi:transaction-mode("update") to make sure it runs in update mode.

You'll have to translate the above to Python of course, but that shouldn't be difficult.

HTH!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.