本文整理汇总了Java中net.sourceforge.subsonic.io.RangeOutputStream类的典型用法代码示例。如果您正苦于以下问题:Java RangeOutputStream类的具体用法?Java RangeOutputStream怎么用?Java RangeOutputStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RangeOutputStream类属于net.sourceforge.subsonic.io包,在下文中一共展示了RangeOutputStream类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: downloadFile
import net.sourceforge.subsonic.io.RangeOutputStream; //导入依赖的package包/类
/**
* Downloads a single file.
*
*
* @param response The HTTP response.
* @param status The download status.
* @param file The file to download.
* @param range The byte range, may be <code>null</code>.
* @throws IOException If an I/O error occurs.
*/
private void downloadFile(HttpServletResponse response, TransferStatus status, File file, HttpRange range) throws IOException {
LOG.info("Starting to download '" + FileUtil.getShortPath(file) + "' to " + status.getPlayer());
status.setFile(file);
response.setContentType("application/x-download");
response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + encodeAsRFC5987(file.getName()));
if (range == null) {
Util.setContentLength(response, file.length());
}
copyFileToStream(file, RangeOutputStream.wrap(response.getOutputStream(), range), status, range);
LOG.info("Downloaded '" + FileUtil.getShortPath(file) + "' to " + status.getPlayer());
}
示例2: downloadFiles
import net.sourceforge.subsonic.io.RangeOutputStream; //导入依赖的package包/类
/**
* Downloads the given files. The files are packed together in an
* uncompressed zip-file.
*
*
* @param response The HTTP response.
* @param status The download status.
* @param files The files to download.
* @param indexes Only download songs at these indexes. May be <code>null</code>.
* @param coverArtFile The cover art file to include, may be {@code null}.
*@param range The byte range, may be <code>null</code>.
* @param zipFileName The name of the resulting zip file. @throws IOException If an I/O error occurs.
*/
private void downloadFiles(HttpServletResponse response, TransferStatus status, List<MediaFile> files, int[] indexes, File coverArtFile, HttpRange range, String zipFileName) throws IOException {
if (indexes != null && indexes.length == 1) {
downloadFile(response, status, files.get(indexes[0]).getFile(), range);
return;
}
LOG.info("Starting to download '" + zipFileName + "' to " + status.getPlayer());
response.setContentType("application/x-download");
response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + encodeAsRFC5987(zipFileName));
ZipOutputStream out = new ZipOutputStream(RangeOutputStream.wrap(response.getOutputStream(), range));
out.setMethod(ZipOutputStream.STORED); // No compression.
List<MediaFile> filesToDownload = new ArrayList<MediaFile>();
if (indexes == null) {
filesToDownload.addAll(files);
} else {
for (int index : indexes) {
try {
filesToDownload.add(files.get(index));
} catch (IndexOutOfBoundsException x) { /* Ignored */}
}
}
for (MediaFile mediaFile : filesToDownload) {
zip(out, mediaFile.getParentFile(), mediaFile.getFile(), status, range);
}
if (coverArtFile != null && coverArtFile.exists()) {
zip(out, coverArtFile.getParentFile(), coverArtFile, status, range);
}
out.close();
LOG.info("Downloaded '" + zipFileName + "' to " + status.getPlayer());
}
示例3: downloadFile
import net.sourceforge.subsonic.io.RangeOutputStream; //导入依赖的package包/类
/**
* Downloads a single file.
*
* @param response The HTTP response.
* @param status The download status.
* @param file The file to download.
* @param range The byte range, may be <code>null</code>.
* @throws IOException If an I/O error occurs.
*/
private void downloadFile(HttpServletResponse response, TransferStatus status, File file, LongRange range) throws IOException {
LOG.info("Starting to download '" + FileUtil.getShortPath(file) + "' to " + status.getPlayer());
status.setFile(file);
response.setContentType("application/x-download");
response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + encodeAsRFC5987(file.getName()));
if (range == null) {
Util.setContentLength(response, file.length());
}
copyFileToStream(file, RangeOutputStream.wrap(response.getOutputStream(), range), status, range);
LOG.info("Downloaded '" + FileUtil.getShortPath(file) + "' to " + status.getPlayer());
}
示例4: downloadDirectory
import net.sourceforge.subsonic.io.RangeOutputStream; //导入依赖的package包/类
/**
* Downloads all files in a directory (including sub-directories). The files are packed together in an
* uncompressed zip-file.
*
* @param response The HTTP response.
* @param status The download status.
* @param file The file to download.
* @param range The byte range, may be <code>null</code>.
* @throws IOException If an I/O error occurs.
*/
private void downloadDirectory(HttpServletResponse response, TransferStatus status, File file, LongRange range) throws IOException {
String zipFileName = file.getName() + ".zip";
LOG.info("Starting to download '" + zipFileName + "' to " + status.getPlayer());
response.setContentType("application/x-download");
response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''"+ encodeAsRFC5987(zipFileName));
ZipOutputStream out = new ZipOutputStream(RangeOutputStream.wrap(response.getOutputStream(), range));
out.setMethod(ZipOutputStream.STORED); // No compression.
zip(out, file.getParentFile(), file, status, range);
out.close();
LOG.info("Downloaded '" + zipFileName + "' to " + status.getPlayer());
}
示例5: downloadFiles
import net.sourceforge.subsonic.io.RangeOutputStream; //导入依赖的package包/类
/**
* Downloads the given files. The files are packed together in an
* uncompressed zip-file.
*
* @param response The HTTP response.
* @param status The download status.
* @param files The files to download.
* @param indexes Only download songs at these indexes. May be <code>null</code>.
* @param range The byte range, may be <code>null</code>.
* @param zipFileName The name of the resulting zip file.
* @throws IOException If an I/O error occurs.
*/
private void downloadFiles(HttpServletResponse response, TransferStatus status, List<MediaFile> files, int[] indexes, LongRange range, String zipFileName) throws IOException {
if (indexes != null && indexes.length == 1) {
downloadFile(response, status, files.get(indexes[0]).getFile(), range);
return;
}
LOG.info("Starting to download '" + zipFileName + "' to " + status.getPlayer());
response.setContentType("application/x-download");
response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + encodeAsRFC5987(zipFileName));
ZipOutputStream out = new ZipOutputStream(RangeOutputStream.wrap(response.getOutputStream(), range));
out.setMethod(ZipOutputStream.STORED); // No compression.
List<MediaFile> filesToDownload = new ArrayList<MediaFile>();
if (indexes == null) {
filesToDownload.addAll(files);
} else {
for (int index : indexes) {
try {
filesToDownload.add(files.get(index));
} catch (IndexOutOfBoundsException x) { /* Ignored */}
}
}
for (MediaFile mediaFile : filesToDownload) {
zip(out, mediaFile.getParentFile(), mediaFile.getFile(), status, range);
}
out.close();
LOG.info("Downloaded '" + zipFileName + "' to " + status.getPlayer());
}