Roundcube Community Forum

Third Party Contributions => API Based Plugins => Topic started by: alpha_beta on March 24, 2013, 12:18:44 PM

Title: download file through plugin
Post by: alpha_beta on March 24, 2013, 12:18:44 PM
Hi,

Download a file using "php readfile" in an action. For example a link "a href=?_task=something&_action=download&file=1"

Upon clicking this link the action should return the file without any html page output.

Any help on how to achieve this will be highly appreciated. I just cant get an understanding of how mail attachment are downloaded.
Title: Re: download file through plugin
Post by: SKaero on March 24, 2013, 01:53:38 PM
You should be able to do it very simply, have you read the plugin documentation? http://trac.roundcube.net/wiki/Doc_Plugins
Title: Re: download file through plugin
Post by: alpha_beta on March 24, 2013, 04:03:56 PM
I read the docs and have implemented couple of plugins. I need to understand a way to achieve this within roundcube's framework probably through pointers with examples.
Title: Re: download file through plugin
Post by: alec on March 25, 2013, 02:32:25 AM
?_task=mail&_action=get&_mbox=INBOX&_uid=123&_part=1&_download=1
Title: Re: download file through plugin
Post by: alpha_beta on March 26, 2013, 01:32:25 PM
Quote from: alec on March 25, 2013, 02:32:25 AM
?_task=mail&_action=get&_mbox=INBOX&_uid=123&_part=1&_download=1

Following the "message part" above I see RC loading another file to handle the download. My aim is to use RC's security feature to control access to the application being implemented. The application is a secondary download link to private files listed in a task not mail attachments.

I tried template hooks http://trac.roundcube.net/wiki/Plugin_Hooks#send_page and emptied the content but I got 2 bytes added to php readfile output.  I decided to go with the code below since the main aim is RC's security and working within its frame.

//file: doreadfile.php
<?php

require_once 'program/include/iniset.php';
$RCMAIL rcmail::get_instance();
if( 
$RCMAIL->session->check_auth()){
//do readfile stuffs here
}

?>


Now the link will point to doreadfile.php. If you have a better way of achieving this within the plugin API or RC's frame please do let me know.