내 타임 라인 항목 디자인 중 여러 이미지가 필요하지만 안정적으로 첨부하는 데 어려움이 있습니다. timeline.insert 함수는 타임 라인 항목을 삽입 한 후에 하나의 첨부 파일을 허용하고 첨부 파일을 삽입하는 경우에만 이미지가 렌더링되지 않을 수 있습니다.여러 이미지를 첨부하는 가장 좋은 방법은 무엇입니까?
타임 라인 항목 자체에서 setAttachments를 사용하여 시도했지만 항목을 삽입 할 때 실제로 첨부 파일을 업로드하지 않은 것 같습니다. 아래 코드를 사용하면 혼합 된 결과를 얻는 경향이 있습니다. 때로는 작동하고 이미지를 렌더링하지 못하는 경우도 있습니다. 알림을받은 후 알림을보기 위해 얼마나 오래 기다려야하는지와 상관 관계가있는 것 같습니다. 너무 빨리 볼 경우 완전히 렌더링되지 않습니다.
아무도 내가 이것을 극복 할 수있는 방법에 대한 의견이나 제안을 갖고 있습니까?
//CardFactory.java - Create TimelineItem with attachment list
public static TimelineItem getConceptCard(String conceptImage) {
TimelineItem timelineItem = new TimelineItem();
timelineItem.setHtml("<article class=\"photo\">\n <img src=\"attachment:0\" width=\"100%\" height=\"100%\">\n <div class=\"photo-overlay\"/>\n <section>\n <p class=\"text-auto-size\">Test</p>\n </section>\n</article>\n");
List<Attachment> attachments = new ArrayList<Attachment>();
Attachment img1 = new Attachment();
img1.setId("backImage");
img1.setContentType("image/jpeg");
img1.setContentUrl(WebUtil.buildStaticImgUrl("cardconcepts/" + conceptImage + ".JPG"));
attachments.add(img1);
timelineItem.setAttachments(attachments);
timelineItem.setNotification(new NotificationConfig().setLevel("DEFAULT"));
return timelineItem;
}
//MainServlet.java - Send TimelineItem on button press
} else if (req.getParameter("operation").equals("insertConceptCard")) {
TimelineItem timelineItem = CardFactory.getConceptCard(req.getParameter("conceptCard"));
MirrorClient.insertTimelineCard(credential, timelineItem);
//MirrorClient.java - Insert TimelineItem with multiple attachments
public static void insertTimelineCard(Credential credential, TimelineItem item) throws IOException {
Mirror.Timeline timeline = getMirror(credential).timeline();
TimelineItem timelineItem = timeline.insert(item).execute();
for(Attachment TAttach : item.getAttachments()){
InputStreamContent mediaContent = new InputStreamContent(TAttach.getContentType(), new URL(TAttach.getContentUrl()).openStream());
timeline.attachments().insert(timelineItem.getId(), mediaContent).execute();
}