Webdev upload fail

	logger = system.util.getLogger("Webdev Debug")
	from org.eclipse.jetty.server import Request
	from javax.servlet import MultipartConfigElement
	from org.apache.commons.io import IOUtils
	
	basereq = request['servletRequest']
	
	basereq.setAttribute(Request.MULTIPART_CONFIG_ELEMENT, MultipartConfigElement(""))
	system.tag.write('[dhProvider]obj_test_float', basereq.getParts())
	for part in basereq.getParts():
		logger.info("%s - %s" % (part.getName(), part.getSize()))
		logger.info(str(part.getSubmittedFileName()))
		system.file.writeFile(part.getSubmittedFileName(), IOUtils.toByteArray(part.getInputStream()))
		system.tag.write('[dhProvider]Obj_0843',part.getSubmittedFileName())
		system.tag.write('[dhProvider]obj_test_float',1)
	return {'html': '<html><body>Hello World</body></html>'}



After uploading the file, basereq Getparts() is an empty array

Oh no haha, what are you doing? The module does the hard work for you, just use this

byteArray = request['data']

I would also use the POST method.

This is the output

Bytearray contains a lot of information. How can you only extract the file information uploaded by yourself

That is the information uploaded. Write those bytes to a file (as bytes) to see for yourself.


How can I extract the data I want, that is, the following

You can not do anything about this, I think a is bug or a limitation.

the WebDev 5.1.7 (b2021060314) module is not ready for multipart/form-data and your desired result.

The work around for this is to include a base64 file in your request. Catch it with base64File = request[‘params’][‘yourparamname’] and decode it with Base64 class

ok