Tag: restlet 2.3.1

使用java中的Restlet multipart / form-data上传文件

所以我现在搜索了相当多的示例代码,但我发现的唯一的事情是服务器端的示例,这意味着接收部分 。 我想创建一个应用程序,它使用restlet上传文件,内容类型: multipart/form-data 。 所以我需要发送部分 如何为此创建表单? 我尝试的是以下,但它不起作用: public void UploadFile(File f){ Form fileForm = new Form(); fileForm.add(Disposition.NAME_FILENAME, “test.jpg”); Disposition disposition = new Disposition(Disposition.TYPE_INLINE, fileForm); FileRepresentation entity = new FileRepresentation(f, MediaType.IMAGE_ALL); entity.setDisposition(disposition); FormData fd = new FormData(“photo”, entity); FormDataSet fds = new FormDataSet(); fds.setMultipart(true); fds.setMediaType(MediaType.MULTIPART_FORM_DATA); fds.getEntries().add(fd); String url = “http://localhost/uploadFile”; Optional opJrep = m_RestClient.postJson(url,fds,MediaType.MULTIPART_FORM_DATA, Optional.empty()); […]

Restlet javax.net.ssl.SSLHandshakeException:null cert chain

我正在本地测试客户端和服务器之间的SSL通信。 所以我使用OpenSSL命令生成证书。 在cacert文件中添加了此证书。 还生成.p12文件。 我在服务器和客户端使用相同的.p12文件。 这是服务器代码 Server server = component.getServers().add(Protocol.HTTPS, port); Series params = server.getContext().getParameters(); params.add(“keystorePath”, “.p12 file path”); params.add(“keystoreType”, “PKCS12”); params.add(“needClientAuthentication”,”true”); component.getDefaultHost().attach(“”, “/AA”), new AAClass()); component.start(); 这是客户端代码: Client client = trustAllCerts(); clientResource = new ClientResource(url); clientResource.setNext(client); try{ clientText = clientResource.post””); } catch(ResourceException e){ e.printStackTrace(); } public Client trustAllCerts() { Client client = null; try […]