@Override public void write (Output output, String boundary, String key, Object value) throws EncodeException { if (value instanceof MultipartFile[]) { val files = (MultipartFile[]) value; for (val file : files) { fileWriter.write(output, boundary, key, file); } } else if (value instanceof Iterable) { val iterable = (Iterable<?>) value; for (val file : iterable) { fileWriter.write(output, boundary, key, file); } } }
/** * Constructor with specified delegate encoder. * * @param delegate delegate encoder, if this encoder couldn't encode object. */ public SpringFormEncoder (Encoder delegate) { super(delegate); val processor = (MultipartFormContentProcessor) getContentProcessor(MULTIPART); processor.addFirstWriter(new SpringSingleMultipartFileWriter()); processor.addFirstWriter(new SpringManyMultipartFilesWriter()); }
@Bean public Encoder feignFormEncoder() { return new SpringFormEncoder(); }
springFormEncoder.encode(requestBody, bodyType, request); return; } else {
@Override protected void write (Output output, String key, Object value) throws EncodeException { val file = (MultipartFile) value; writeFileMetadata(output, key, file.getOriginalFilename(), file.getContentType()); byte[] bytes; try { bytes = file.getBytes(); } catch (IOException ex) { throw new EncodeException("Getting multipart file's content bytes error", ex); } output.write(bytes); } }
springFormEncoder.encode(requestBody, bodyType, request); return; } else {