我们正在寻找使用 orbot 上传图像的解决方案。我们正在使用 Android 客户端来实现它,并使用服务器端 Spring Boot。当我们上传图片(3 张或更多图片)时,即使上传了图片,我们也会在 Android 中获得 Socket Exception。
这是 Spring 的示例代码:
public @ResponseBody Response addAttachments(@ModelAttribute("atForm") AtForm atForm, @RequestHeader(value="ts", required=false) String ts) throws Exception {
Response res = new Respose();
saveAttachments(atForm.getAtachments(), ts);
return response;
}
private void saveAttachments(MultipartFile[] attachments, String ts) {
if(attachments!=null && attachments.length > 0) {
for(MultipartFile file : attachments){
saveFile(file);
}
}
}
public String saveFile(MultipartFile mFile) throws IOException {
File convFile = new File(PATH+mFile.getOriginalName());
FileCopyUtils.copy(mFile.getBytes(), convFile);
return fileName.toString();
}