Hi
I added a new construct/button to upload firmware update files on the UI. With the new upload button user can now select a file on the disk to be uploaded to the device. The file is transferred to the device but the contents are not correct. The file is uploaded using "multipart/form-data". I added another else block in ClientServlet.java
else if ("multipart/form-data".equals(contentType)) {
String content = IOUtils.toString(req.getInputStream(), parameters.get("charset"));
LwM2mNode node;
try {
node = gson.fromJson(content, LwM2mNode.class);
} catch (JsonSyntaxException e) {
throw new IllegalArgumentException("unable to parse json to tlv:" + e.getMessage(), e);
}
return server.send(client, new WriteRequest(Mode.REPLACE, null, target, node), TIMEOUT);
}
Has anybody tried to upload a file to device ?
If instead of upload/browse gui which is using "multipart/form-data", I transfer file in java test code by reading it in to a byte array and then sending it to the device, the content is correct.
We are still in ths POC(Proof Of Concept) stage so I am still using Jetty. Wondering if anybody has tried uploading a file with Jetty ?
I also added MultipartConfigElement to ClientServlet.java
clientServletHolder.getRegistration().setMultipartConfig(new MultipartConfigElement(System.getProperty("java.io.tmpdir")));
@MultipartConfig
public class ClientServlet extends HttpServlet {
Thanks