gpt4 book ai didi

android - Robospice 上传文件问题

转载 作者:行者123 更新时间:2023-11-29 15:23:29 26 4
gpt4 key购买 nike

我是 RoboSpice 的新手.我正在尝试上传文件。但是我得到了这个错误:

 04-02 17:47:31.151: E//RequestProcessor.java:234(11021): org.springframework.web.client.RestClientException: Could not extract response: no suitable HttpMessageConverter found for response type [java.lang.String] and content type [text/html]

.这是我的请求类:

public class UploadFileRequest extends SpringAndroidSpiceRequest<String>{
private static final String TAG = "UploadFileRequest";
private UploadRequestModel requestModel;
private String link;

public UploadFileRequest(UploadRequestModel model, String link) {
super(String.class);
requestModel = model;
this.link = link;
}

@Override
public String loadDataFromNetwork() throws Exception {


MultiValueMap<String, Object> parts = new LinkedMultiValueMap<String, Object>();
parts.add("file1", new FileSystemResource(requestModel.getFile1()));
parts.add("file2", new FileSystemResource(requestModel.getFile1()));
return getRestTemplate().postForObject(link, parts, String.class);


}

}

我正在使用:JacksonSpringAndroidSpiceService 类。

非常感谢您的帮助。

最佳答案

JacksonSpringAndroidSpiceService可以看出source code ,它仅通过 MappingJacksonHttpMessageConverter 类为 application/json 内容类型提供转换器。

对于任何其他内容类型,Spring 不知道如何处理它。

您可以使用 StringHttpMessageConverter 类子类 JacksonSpringAndroidSpiceService 轻松添加通用目的转换器,或基于其源代码创建您自己的实现。

关于android - Robospice 上传文件问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15762284/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com