Skip to content

Commit

Permalink
Task #205 feat : File download functionality from backend
Browse files Browse the repository at this point in the history
  • Loading branch information
“Rajnish committed Nov 28, 2019
1 parent 3ee31f1 commit f634525
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions administrator/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public function display($cachable = false, $urlparams = false)
*/
public function getMediaFile()
{
(JSession::checkToken() or JSession::checkToken('get')) or jexit(JText::_('JINVALID_TOKEN'));
JLoader::import("/techjoomla/media/storage/local", JPATH_LIBRARIES);
$app = Factory::getApplication();
$jinput = $app->input;
Expand Down
1 change: 1 addition & 0 deletions site/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function __construct()
*/
public function getMediaFile()
{
(JSession::checkToken() or JSession::checkToken('get')) or jexit(JText::_('JINVALID_TOKEN'));
JLoader::import("/techjoomla/media/storage/local", JPATH_LIBRARIES);
$app = Factory::getApplication();
$jinput = $app->input;
Expand Down
5 changes: 4 additions & 1 deletion site/helpers/tjfields.php
Original file line number Diff line number Diff line change
Expand Up @@ -1927,7 +1927,10 @@ public function getMediaUrl($fileName, $extraUrlParamsArray = '')
// Here, fpht means file encoded path
$encodedFileName = base64_encode($fileName);
$basePathLink = 'index.php?option=com_tjfields&task=getMediaFile&fpht=';
$mediaURLlink = Uri::base() . substr(Route::_($basePathLink . $encodedFileName . $extraUrlParams), strlen(Uri::base(true)) + 1);
$mediaURL = Uri::base() . substr(Route::_($basePathLink . $encodedFileName . $extraUrlParams), strlen(Uri::base(true)) + 1);

$csrf = JSession::getFormToken() . '=1';
$mediaURLlink = $mediaURL . '&' . $csrf;

return $mediaURLlink;
}
Expand Down

0 comments on commit f634525

Please sign in to comment.