/** * @see Media#getName() */ public String getName() { return _media.getName(); }
/** * @see Media#isBinary() */ public boolean isBinary() { return _media.isBinary(); }
/** * @see Media#getByteData() */ public byte[] getByteData() { return _media.getByteData(); }
synchronized (media) { //Bug 1896797: media might be accessed concurrently. final String ctype = media.getContentType(); if (ctype != null) response.setContentType(ctype); ); } else flnm = media.getName(); if (media.isContentDisposition()) response.setHeader("Content-Disposition", value); if (!media.inMemory()) { final ServletOutputStream out = response.getOutputStream(); if (media.isBinary()) { InputStream in = media.getStreamData(); if (repeatable) in = RepeatableInputStream.getInstance(in); Reader in = media.getReaderData(); if (repeatable) in = RepeatableReader.getInstance(in); data = media.isBinary() ? media.getByteData() : media.getStringData().getBytes(getCharset(ctype));
return; if (media.isBinary()) { m_file_istream = media.getStreamData(); m_file_istream = new ReaderInputStream(media.getReaderData()); } else { Charset charset = (Charset)listitem.getValue(); m_file_istream = new ReaderInputStream(media.getReaderData(), charset.name()); log.config(media.getName()); bFile.setLabel(media.getName());
/** * Parse the media list into Array, * if the list is empty or null, the return value will be null. * * @param result the media list * @return the media array */ public static Media[] parseResult(List<Media> result) { if (result != null) { //we have to filter items that user doesn't specify any file for (Iterator<Media> it = result.iterator(); it.hasNext(); ) { final Media media = it.next(); if (media != null && media.inMemory() && media.isBinary()) { final String nm = media.getName(); if (nm == null || nm.length() == 0) { final byte[] bs = media.getByteData(); if (bs == null || bs.length == 0) it.remove(); //Upload is pressed without specifying a file } } } if (!result.isEmpty()) return result.toArray(new Media[result.size()]); } return null; } }
/** * Returns a repeatable media with a repeatable input stream or * reader, or null if the given media is null. */ public static Media getInstance(Media media) { if (media != null && !media.inMemory() && !(media instanceof RepeatableMedia)) { if (media.isBinary()) { final InputStream data = media.getStreamData(), after = RepeatableInputStream.getInstance(data); if (data != after) return new RepeatableMedia(media, after); } else { final Reader data = media.getReaderData(), after = RepeatableReader.getInstance(data); if (data != after) return new RepeatableMedia(media, after); } } return media; }
int day = now.get(Calendar.DAY_OF_MONTH); int min = now.get(Calendar.MINUTE); String originalName = media.getName(); System.out.println("filePath='"+filePath+"'"); Files.copy(new File(filePath), media.getStreamData());
/** * @see Media#getFormat() */ public String getFormat() { return _media.getFormat(); }
/** * @see Media#isContentDisposition() */ public boolean isContentDisposition() { return _media.isContentDisposition(); } }
/** * @see Media#getContentType() */ public String getContentType() { return _media.getContentType(); }
/** * @see Media#getStringData() */ public String getStringData() { return _media.getStringData(); }
/** * @see Media#inMemory() */ public boolean inMemory() { return _media.inMemory(); }
private DownloadURL(Media media, String flnm) { _media = media; if (flnm == null) flnm = media.getName(); final StringBuffer sb = new StringBuffer(32); if (flnm != null && flnm.length() != 0) { sb.append('/'); sb.append(flnm); if (flnm.lastIndexOf('.') < 0) { final String format = media.getFormat(); if (format != null) sb.append('.').append(format); } } _path = sb.toString(); }