问题描述
我想通过网络服务发送 from math import floor
from PIL import Image
from random import randint
# Read all images
c=1
times = int(input("How many times to save"))
for i in range(times):
bckgnd = Image.open('background2.png').convert('RGBA')
orangedot = Image.open('orangedot.png')
whiteX = Image.open('whiteX.png')
# Width and height of each "tile"
w,h = bckgnd.size
# Calculate number of tiles for x and y direction by A4 paper size
# (21 cm x 29.7 cm),and some resolution like dpi = 300
n_tiles = (floor((21.0 / 2.54 * 300) / w),floor((29.7 / 2.54 * 300) / h))
# Prepare final image of sufficient size
final_img = Image.new('RGBA',(n_tiles[0] * w,n_tiles[1] * h),color=(0,0))
# Iterate all tiles
for i_x in range(n_tiles[0]):
for i_y in range(n_tiles[1]):
# Upper left (x,y) coordinates of current tile
x,y = i_x * w,i_y * h
# 1st: Paste background to current tile
final_img.paste(bckgnd,(x,y),mask=bckgnd)
# 2nd: Randomly generate location of orange dot and paste to current tile
od_x,od_y = randint(30,170),randint(0,100)
final_img.paste(orangedot,(x + od_x,y + od_y),mask=orangedot)
# 3rd: Paste white X to current tile
final_img.paste(whiteX,mask=whiteX)
# Save and show final image
img_name = 'filename0{0}.png'.format(c)
c+=1
final_img.save(img_name)
列表。下面我用wrapper class发送multipartfile
列表
它仅适用于字符串列表。
这是我的包装类
multipartfile
下面是我如何在休息模板中发送列表
@Data
public class FileList {
private String fileName;
private List arrayList;
}
吹你可以看到我的第二个应用程序的休息结束点。
final String uri = "http://localhost:9000/api/file/login";
fileList.setFileName("Samana");
fileList.setArrayList(Arrays.asList(new String[]{"A","B","C","D"}));
org.springframework.http.HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
RestTemplate restTemplate = new RestTemplate();
httpentity<FileList> entity = new httpentity<>(fileList,headers);
ResponseEntity<String> response = restTemplate.exchange(uri,HttpMethod.POST,entity,String.class);
这适用于 @PostMapping(value = "/login")
public String createEmployee(@RequestBody FileList fileList) {
//Some codes goes here
return null;
}
我想在 fileList.setArrayList(Arrays.asList(new String[]{"A","D"}));
的包装类中发送 List<multipartfile>
insted of FileList
如何做到这一点?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)