1 <?php
2 /**
3 * @package FrameworkOnFramework
4 * @subpackage dispatcher
5 * @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
6 * @license GNU General Public License version 2 or later; see LICENSE.txt
7 */
8 // Protect from unauthorized access
9 defined('FOF_INCLUDED') or die;
10
11 interface FOFDownloadInterface
12 {
13 /**
14 * Does this download adapter support downloading files in chunks?
15 *
16 * @return boolean True if chunk download is supported
17 */
18 public function supportsChunkDownload();
19
20 /**
21 * Does this download adapter support reading the size of a remote file?
22 *
23 * @return boolean True if remote file size determination is supported
24 */
25 public function supportsFileSize();
26
27 /**
28 * Is this download class supported in the current server environment?
29 *
30 * @return boolean True if this server environment supports this download class
31 */
32 public function isSupported();
33
34 /**
35 * Get the priority of this adapter. If multiple download adapters are
36 * supported on a site, the one with the highest priority will be
37 * used.
38 *
39 * @return boolean
40 */
41 public function getPriority();
42
43 /**
44 * Returns the name of this download adapter in use
45 *
46 * @return string
47 */
48 public function getName();
49
50 /**
51 * Download a part (or the whole) of a remote URL and return the downloaded
52 * data. You are supposed to check the size of the returned data. If it's
53 * smaller than what you expected you've reached end of file. If it's empty
54 * you have tried reading past EOF. If it's larger than what you expected
55 * the server doesn't support chunk downloads.
56 *
57 * If this class' supportsChunkDownload returns false you should assume
58 * that the $from and $to parameters will be ignored.
59 *
60 * @param string $url The remote file's URL
61 * @param integer $from Byte range to start downloading from. Use null for start of file.
62 * @param integer $to Byte range to stop downloading. Use null to download the entire file ($from is ignored)
63 * @param array $params Additional params that will be added before performing the download
64 *
65 * @return string The raw file data retrieved from the remote URL.
66 *
67 * @throws Exception A generic exception is thrown on error
68 */
69 public function downloadAndReturn($url, $from = null, $to = null, array $params = array());
70
71 /**
72 * Get the size of a remote file in bytes
73 *
74 * @param string $url The remote file's URL
75 *
76 * @return integer The file size, or -1 if the remote server doesn't support this feature
77 */
78 public function getFileSize($url);
79 }