java - Replace an image resource on a jasperserver via Java REST API v7.2.0
问题描述
I am trying to upload reports and resources for these reports via the java rest api v7.2.0 on a jasperserver.
I found that upload an image could be done like so :
RestClientConfiguration configuration = new RestClientConfiguration("http://127.0.0.1:8082/jasperserver");
configuration.setLogHttp(true);
configuration.setLogHttpEntity(true);
configuration.setJrsVersion(JRSVersion.v6_1_0);
configuration.setRestrictedHttpMethods(false);
JasperserverRestClient client = new JasperserverRestClient(configuration);
Session session = client.authenticate("jasperadmin", "jasperadmin");
session.resourcesService().resource("/images").uploadFile(new File("logo.png"), ClientFile.FileType.img, "logo.png", "logo.png"));
But this exact same code fail if the image already exists, but I would like to overwrite the image, in case it must be updated.
The problem is that I can't delete then upload again the image as if it is referenced in a report it will generate and error.
How can I replace an already present image via the rest api ?
解决方案
Ok, I found how to « update » a resource file on a jasper server using the rest api.
If someone go check the definition of the rest api, you could see that they use POST for creation and PUT for update.
The problem is that the java rest client library only provide a method that will only use POST, you have to find a way to had a method to switch the call of post by a call for put.
推荐阅读
- asp.net-mvc - '值不能为空。参数名称:ViewStart.cshtml 上的 virtualPath'
- c# - Win2D API 随机失败,并出现错误“必须从同一工厂实例创建一起使用的对象”。
- android - 在 Android 屏幕录制中 - 如何获取每一帧?
- c# - 如何停止项目模板概念中的向导操作(IWizard)
- excel - 如何在同一类别下仅识别一个最小的数字
- powershell - 在powershell中将system.array对象转换为json对象
- python - 如何从 argparse 解析器对象中查询我期望的参数类型?
- wordpress - 使用 wpml 插件联系表格 7 占位符文本翻译
- php - 如何在没有参数的情况下将 WordPress URL 重定向到基本 url
- angular - 在提交构建代码时出现错误:“在堆限制附近分配无效的标记压缩失败 - JavaScript 堆内存不足”