public void fromXML(Element docel) throws XWikiException { setFilename(docel.element("filename").getText()); setFilesize(Integer.parseInt(docel.element("filesize").getText())); setAuthor(docel.element("author").getText()); setVersion(docel.element("version").getText()); setComment(docel.element("comment").getText()); String sdate = docel.element("date").getText(); Date date = new Date(Long.parseLong(sdate)); setDate(date); Element contentel = docel.element("content"); if (contentel != null) { String base64content = contentel.getText(); byte[] content = Base64.decodeBase64(base64content.getBytes()); setContent(content); } Element archiveel = docel.element("versions"); if (archiveel != null) { String archive = archiveel.getText(); setArchive(archive); } }
this.attachment.setFilesize(json.getInt(JSON_FIELD_FILESIZE)); if (json.has(JSON_FIELD_AUTHOR)) { this.attachment.setAuthorReference(this.userResolver.resolve(json.getString(JSON_FIELD_AUTHOR)));
@Override public XWikiAttachment parse(final Element docel) throws IOException { if (!ROOT_ELEMENT_NAME.equals(docel.getName())) { throw new IOException("XML not recognizable as attachment metadata, expecting <attachment> tag"); } if (docel.attribute(SERIALIZER_PARAM) == null || !THIS_SERIALIZER.equals(docel.attribute(SERIALIZER_PARAM).getValue())) { throw new IOException("Cannot parse this attachment metadata, it was saved with a different " + "serializer."); } final XWikiAttachment out = new XWikiAttachment(); out.setFilename(docel.element(FILENAME).getText()); out.setFilesize(Integer.parseInt(docel.element(FILESIZE).getText())); out.setAuthor(docel.element(AUTHOR).getText()); out.setVersion(docel.element(VERSION).getText()); out.setComment(docel.element(COMMENT).getText()); final String sdate = docel.element(DATE).getText(); final Date date = new Date(Long.parseLong(sdate)); out.setDate(date); return out; }
/** * Set the content of the attachment from an InputStream. * * @param is the input stream that will be read * @throws IOException when an error occurs during streaming operation * @since 2.6M1 */ public void setContent(InputStream is) throws IOException { this.newFileItem(); IOUtils.copy(is, this.file.getOutputStream()); this.setContentDirty(true); this.attachment.setFilesize(this.getSize()); }
xattachment.setFilesize((int) report.getFilesize()); return report.getFilename();
xattachment.setFilesize((int) file.getFilesize()); xobject.setStringValue(FILE_FIELD_NAME, file.getFilename()); xobject.setLargeStringValue(COMMENTS_FIELD_NAME, (String) file.getAttribute(COMMENTS_FIELD_NAME));
xattachment.setFilesize((int) image.getFilesize()); xobject.setStringValue(FILE_FIELD_NAME, image.getFilename()); xobject.setLargeStringValue(COMMENTS_FIELD_NAME, (String) image.getAttribute(COMMENTS_FIELD_NAME));
attachment.setDoc(getDoc()); attachment.setFilename(getFilename()); attachment.setFilesize(getFilesize()); attachment.setRCSVersion(getRCSVersion()); if (getAttachment_content() != null) {