Peejay Posted April 11, 2017 Share Posted April 11, 2017 Hi all! Is it possible to use this module on your localhost (Mamp), for testing? Where do you place te folder? Cheers! Link to comment Share on other sites More sharing options...
Wanze Posted April 13, 2017 Author Share Posted April 13, 2017 @Peejay Of course, it doesn't matter where you place the folder as long as the user running apache has write permission. So for testing purposes, you could also place the folder inside the document root. Cheers 1 Link to comment Share on other sites More sharing options...
Peejay Posted April 19, 2017 Share Posted April 19, 2017 On 4/13/2017 at 10:03 AM, Wanze said: @Peejay Of course, it doesn't matter where you place the folder as long as the user running apache has write permission. So for testing purposes, you could also place the folder inside the document root. Cheers Your solution worked! I wil see what happens when I place the website online. I found a little issue: The download link doesn't work when the secure fieldtype is used in the user template file. You get this link: {your site}admin/access/users/?id=41&ftsd=document_1.pdf (-> then you go to the users list) But when je place "edit" after users/, the download link works!: {your site}admin/access/users/edit/?id=41&ftsd=document_1.pdf Cheers! Link to comment Share on other sites More sharing options...
Macrura Posted November 4, 2017 Share Posted November 4, 2017 I needed a way for the files to not force download, so that admin users can quickly view a document in their browser; i added this to the hookDownloadFile() method: $options = []; if($this->wire('input')->get('view')) { $options['forceDownload'] = false; } and then added options to the download: $file->download($options); // Access check performed by this method up in the hookRenderItem i added this: $segments['view'] = 1; $link = $this->wire('page')->url . '?' . http_build_query($segments); $markup .= " | <a href='{$link}' target='_blank'><i class='fa fa-eye'></i> " . $this->_('View File') . "</a>"; $markup .= "</div>"; so now the file looks like this: It would be cool to consider adding this functionality, since it can't always be assumed that the files should force download; maybe it needs to be a config option where you choose the behavior or opt in for download and/or view links... 2 2 Link to comment Share on other sites More sharing options...
Macrura Posted November 6, 2017 Share Posted November 6, 2017 Also, for the field to work in lister/lister pro, some additional changes needed to be made to how the links to the download are formed; this is the complete hookRenderItem method; so basically instead of referencing the page being edited, it would need to reference the $pagefile->page; then since the editUrl already has the id, you don't need to have that in the $segments array.. this works now in listers if you show a secure files field, when it renders in the list you can click on the item to download/view the file... public function hookRenderItem(HookEvent $event) { /** @var PagefileSecure $pagefile */ $pagefile = $event->arguments('pagefile'); if (!$pagefile instanceof PagefileSecure) { return; } $markup = $event->return; $markup = preg_replace("/<a class='InputfieldFileName'[^>]*>(.*)<\/a>/", "$1", $markup); if ($pagefile->field->get('allowDownloadInAdmin') && $pagefile->isDownloadable()) { $segments = array( //'id' => $this->wire('input')->get('id'), self::GET_VAR_DOWNLOAD => urlencode($pagefile->basename), ); //$link = $this->wire('page')->url . '?' . http_build_query($segments); $link = $pagefile->page->editUrl . '&' . http_build_query($segments); $markup .= "<div class='FieldtypeSecureFileDownload InputfieldFileData'><a href='{$link}'><i class='fa fa-download'></i> " . $this->_('Download File') . "</a>"; $segments['view'] = 1; //$link = $this->wire('page')->url . '?' . http_build_query($segments); $link = $pagefile->page->editUrl . '&' . http_build_query($segments); $markup .= " | <a href='{$link}' target='_blank'><i class='fa fa-eye'></i> " . $this->_('View File') . "</a>"; $markup .= "</div>"; } $event->return = $markup; } after additional testing, i can consider forking and pull request, but wanted to run this by here on the forum first.. also haven't setup a module config to account for the showing pref (view and or download).. will possibly get to that soon.. 2 Link to comment Share on other sites More sharing options...
Wanze Posted November 17, 2017 Author Share Posted November 17, 2017 @Macrura Muchas gracias for your additions! Could you open a pull request against the "dev" branch? I would like to integrate your features Cheers 1 Link to comment Share on other sites More sharing options...
Macrura Posted November 17, 2017 Share Posted November 17, 2017 ok will do asap. Link to comment Share on other sites More sharing options...
Wanze Posted December 6, 2017 Author Share Posted December 6, 2017 A little information for the observers here: The feature to view a secret file beside the forced download is now available in version 1.0.3. Thanks @Macrura! I introduced an additional setting on field level to toggle the "View" possibility. Cheers 2 Link to comment Share on other sites More sharing options...
pwfans Posted May 2, 2018 Share Posted May 2, 2018 Make it compatible to pw 3.x please .. Link to comment Share on other sites More sharing options...
dragan Posted May 2, 2018 Share Posted May 2, 2018 Try to add PW namespace at the very top of the .module file: <?php namespace ProcessWire; Lots of older modules can be made PW3-compatible that way... worth a try anyway. 1 Link to comment Share on other sites More sharing options...
Macrura Posted May 2, 2018 Share Posted May 2, 2018 6 hours ago, pwfans said: Make it compatible to pw 3.x please .. @pwfans i have it running well on a large PW3 site. Did you run into some problem? I didn't need to add any namespace or do anything in particular, it just works. 2 Link to comment Share on other sites More sharing options...
flydev Posted May 9, 2018 Share Posted May 9, 2018 hey @Wanze I stumbled into an issue after updating the module I ran into some time ago before deploying a site on a Windows 2008 server. The issue is described there And the fix there : Each time I don't remember where the issue come from and I have to google it and re-read my thread. Are willing to accept a PR ? 1 Link to comment Share on other sites More sharing options...
Krlos Posted August 14, 2018 Share Posted August 14, 2018 (edited) Hello, I'm trying to make this module to work but It seems that my Processwire knowledge is not enough to make it work. I have a user profile with some pdf files that I need to be secured for every user. Only the owner can dowload his/her own files. So, I added the custom field 'profile-contract' to the system user template, so far so good. The secure file module is saving the files outside of the document root. Now I have created a new template in the front end (profile.php) so users can download their files and access other information about their profile. I have been using this: $user->profile_name, $user->birth_date etc to access custom field data from the user template and printed to the profile.php template The question is how can I make a link to download a secured file stored in the user system template?, in this case a custom field named $user->profile_contract in to the profile.php template Thank you. Edited August 15, 2018 by Krlos Typo Link to comment Share on other sites More sharing options...
flydev Posted August 16, 2018 Share Posted August 16, 2018 On 8/14/2018 at 7:53 PM, Krlos said: The question is how can I make a link to download a secured file stored in the user system template?, in this case a custom field named $user->profile_contract in to the profile.php template @Krlos You can echo a link to the external file like that (I might not understood all the issue...) : echo $user->profile_contract->first()->filename; To offer a download to your client, check this tutorial and adapt it for your needs (credit: @jmartsch) : https://jensmartsch.de/blog/simple-file-downloads-with-processwire/ 1 Link to comment Share on other sites More sharing options...
Krlos Posted August 30, 2018 Share Posted August 30, 2018 Hello Again! I was able to make this module work... but now my client wants to open the PDF file on a lightbox or something so users don't need to download and open the files everytime. I have tried many things but browers allways open download prompt, there is a way I can alter the behavior? Much appreciated Link to comment Share on other sites More sharing options...
horst Posted August 30, 2018 Share Posted August 30, 2018 AFAIK, this is a browser specific setting, that you hardly can override if you only serve a download link. But if you use a service like g**gle docs, it should work: https://nogajski.de/autosoftproof/ (the last link in the list) Link to comment Share on other sites More sharing options...
Macrura Posted August 30, 2018 Share Posted August 30, 2018 2 hours ago, Krlos said: I have tried many things but browers allways open download prompt, there is a way I can alter the behavior? there is, at least in the dev branch (not sure if it was committed to main) – there should be a download file, and a view file option. and if you are serving the file, make sure to supply the $options, with ['forceDownload'] => false Link to comment Share on other sites More sharing options...
horst Posted August 30, 2018 Share Posted August 30, 2018 1 hour ago, Macrura said: $options, with ['forceDownload'] => false That is exactly what cannot override the customers private browser setting for file downloads of type PDF. If you serve a file of type PDF you can tell the browser "your wishes", but every individual browser may have its own preferences that cannot be overridden. I had understand that it should be not downloaded but directly shown as document, what only can be asured if you also provide the app for displaying the doc, as you don't know if a browser has a setting that enables such a behave. Link to comment Share on other sites More sharing options...
Krlos Posted August 30, 2018 Share Posted August 30, 2018 2 minutes ago, horst said: That is exactly what cannot override the customers private browser setting for file downloads of type PDF. If you serve a file of type PDF you can tell the browser "your wishes", but every individual browser may have its own preferences that cannot be overridden. Exactly, I know about this. Could be posible to capture the download file and open it in pdf.js for example? Right now I'm using secure file like this: I pass the file ID to a download template where it queries and serve the file. I was experimenting with Fancybox, usign this code: <a data-fancybox data-type="iframe" data-src="download/?=fid" href="javascript:;"> Sample PDF file </a> If I use a hardcoded or a relative pdf url it woks, but as SecureFile has no URL (As far as I know) I'm getting an error not found. Link to comment Share on other sites More sharing options...
Macrura Posted August 30, 2018 Share Posted August 30, 2018 The download url is the $page editor, with some parameters; the person accessing the file needs the correct role/perms the file has to be delivered to the browser, since it is in a non-web accessible location. Link to comment Share on other sites More sharing options...
NorbertH Posted September 3, 2018 Share Posted September 3, 2018 When setting description fields to 0 the download links are not displayed in backend. ProcessWire 3.0.98 Link to comment Share on other sites More sharing options...
cb2004 Posted November 8, 2018 Share Posted November 8, 2018 I discovered this module today. Fantastic. Link to comment Share on other sites More sharing options...
cb2004 Posted November 5, 2019 Share Posted November 5, 2019 On 9/3/2018 at 2:37 PM, NorbertH said: When setting description fields to 0 the download links are not displayed in backend. ProcessWire 3.0.98 Same here. Any chance of a fix @Wanze. I use this module a lot. Link to comment Share on other sites More sharing options...
Testic Posted February 12, 2020 Share Posted February 12, 2020 I was not able to make this work on due to the following issue: ProcessWire: ProcessUser: Secure File: Path '/' does not exist or is not writeable I have tried multiple directories and approaches to change permissions, but PW could simply not find the path I specified with pwd. I am running the local server on Processwire 3.0.148. Any suggestions? Link to comment Share on other sites More sharing options...
k07n Posted February 12, 2020 Share Posted February 12, 2020 31 minutes ago, Testic said: ProcessWire: ProcessUser: Secure File: Path '/' does not exist or is not writeable U need absolute/relative filepath but not url. Ex: /var/www/secure/ or c:\www\secure or something like ./../secure if U use windows local server and linux production server 3 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now