goldsky / FileDownload-R

FileDownload snippet for MODX revolution
12 stars 7 forks source link

Error when using Media Source without baseUrl (above doc root) #57

Closed labr1005 closed 7 years ago

labr1005 commented 7 years ago

Using a Media Source that has no baseUrl set and the basePath set to absolute, e.g. when using a directory above the doc root, produces these errors for me when downloading a file using FileDownloadLink.

Media Source basePath: /xxxxxx/private/uploads/ basePathRelative: No baseUrl: baseUrlReletave: Yes/No (doesn't matter)

Requested file (absolute path): /xxxxxx/private/uploads/sub/file.pdf

The file is being downloaded.

But the MODX error log shows this (this is the entry for a single download, not for multiple tries):

[2016-11-24 14:28:04] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1565) PHP warning: filemtime(): stat failed for /sub/file.pdf
[2016-11-24 14:28:04] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1571) PHP warning: filesize(): stat failed for /sub/file.pdf
[2016-11-24 14:28:05] (ERROR @ /xxxxxx/core/cache/includes/elements/modsnippet/173.include.cache.php : 28) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:05] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1561) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:05] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1562) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:05] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1563) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:05] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1564) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:05] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1565) PHP warning: filemtime(): stat failed for /sub/file.pdf
[2016-11-24 14:28:05] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1565) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:05] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1566) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:05] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1567) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:05] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1568) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:05] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1569) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:05] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1570) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:05] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1571) PHP warning: filesize(): stat failed for /sub/file.pdf
[2016-11-24 14:28:05] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1571) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:05] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1572) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:07] (ERROR @ /xxxxxx/core/cache/includes/elements/modsnippet/173.include.cache.php : 28) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:07] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1561) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:07] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1562) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:07] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1563) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:07] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1564) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:07] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1565) PHP warning: filemtime(): stat failed for /sub/file.pdf
[2016-11-24 14:28:07] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1565) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:07] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1566) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:07] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1567) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:07] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1568) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:07] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1569) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:07] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1570) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:07] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1571) PHP warning: filesize(): stat failed for /sub/file.pdf
[2016-11-24 14:28:07] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1571) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:07] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1572) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:08] (ERROR @ /xxxxxx/core/cache/includes/elements/modsnippet/173.include.cache.php : 28) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:08] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1561) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:08] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1562) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:08] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1563) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:08] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1564) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:08] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1565) PHP warning: filemtime(): stat failed for /sub/file.pdf
[2016-11-24 14:28:08] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1565) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:08] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1566) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:08] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1567) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:08] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1568) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:08] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1569) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:08] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1570) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:08] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1571) PHP warning: filesize(): stat failed for /sub/file.pdf
[2016-11-24 14:28:08] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1571) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:08] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1572) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:09] (ERROR @ /xxxxxx/core/cache/includes/elements/modsnippet/173.include.cache.php : 28) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:09] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1561) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:09] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1562) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:09] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1563) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:09] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1564) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:09] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1565) PHP warning: filemtime(): stat failed for /sub/file.pdf
[2016-11-24 14:28:09] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1565) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:09] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1566) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:09] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1567) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:09] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1568) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:09] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1569) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:09] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1570) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:09] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1571) PHP warning: filesize(): stat failed for /sub/file.pdf
[2016-11-24 14:28:09] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1571) PHP warning: Cannot modify header information - headers already sent
[2016-11-24 14:28:09] (ERROR @ /xxxxxx/core/components/filedownloadr/model/filedownloadr/filedownloadr.class.php : 1572) PHP warning: Cannot modify header information - headers already sent
labr1005 commented 7 years ago

Ok, got it. I'm not sure if this is also related to ContentBlocks, because I'm using FileDownloadLink inside a CB File Input field.

In that case this works for me:

Media Source basePath: /xxxxxx/private/uploads/ basePathRelative: No baseUrl: /xxxxxx/private/uploads/ baseUrlReletave: No

Choose this Media Source in the CB field property Media Source Override.

Set &mediaSourceId=0 for the FileDownloadLink snippet call in the CB template.