PrivateFiles

Share downloads only with the users you want.

Back to PrivateFiles Support

neidoux
neidoux

Hi,

So far really happy with this plugin, however I've noticed that when the file is downloaded, the file extension appears to be dropped off.... so unless the end user saves the file with a file extension - the file can't be opened after downloading by some users.

I've also run into an issue adding a thumbnail - which threw exceptions on "Private Files" menu page... I was unable unable to remove the plugin for a while due to error "Undefined variable: table" on line 14 of /var/www/vhosts/"domain.com"/httpdocs/plugins/kurtjensen/privatefiles/updates/change_permission_nulable.php

I've rectified issues except for the file extension is not there when a user goes to save file - which is really important for the users. Can it be amended so it's appended to the filename on save?

Last updated

KurtJensen
KurtJensen

I have found and fixed the issue in "privatefiles/updates/change_permission_nulable.php". Sorry about that error on my part and thank you for reporting.

The file extension is set when you upload the file. On the front end, the file name and extension are the same as what you uploaded unless you specify it in the Public File Name text field. That is where you would want the file extension added to any text in there.

Not sure about the thumbnail issue that you mentioned but it sounds like you figured that out anyway.

Let me know if I can be of more help. Kurt

KurtJensen
KurtJensen

Just for giggles, I decided to play a little more with the plugin and noticed that there is an issue with the file name and extension. I will see if I can get this fixed for you very soon.

Sorry for your trouble... Kurt

KurtJensen
KurtJensen

Here is what I found: In Chrome ( on Linux ), PDF files open when clicked due to an extension in Chrome and when I click button to save, the file name was not preserved but instead tried to save as "document.pdf". In Firefox ( on Linux ) the PDF file opens but saves as the proper file name and extension.

If I right click and "Save Link as" instead of simple click in either browser, the file name is correct to the Public File Name that I set for the download.

So it is possible that browsers are also dropping the file extension which may mean that I need to update the file headers to prevent this on download. Currently I am defaulting to the headers provided by October CMS for the Database Attached Files.

Last updated

Hessel
Hessel

Hi Kurt, I'm struggling with this issue to. The plugin is beautiful but the files are saved without extension.

I use your plugin for a community and a workaround is to tell the users: "each file you download you have to add the file extension when saving". but that is not professional.

I found this example below, but it is not dynamic. Do you have a correct code fix that I can use on the page code tab that supports pdf and doc/docx files? or perhaps add dl.privatefile.extension tot the download link?

function onDownload() { $pathToFile = Url::to("/storage/app/media/a.pdf"); $fileName = "download.pdf"; $headers = [ 'HTTP/1.1 200 OK', 'Pragma: public', 'Content-Type: application/pdf' ]; return Response::download($pathToFile, $fileName, $headers); }

p.s. I just look for a quick fix, not an plugin version update.

Last updated

KurtJensen
KurtJensen

A few questions:

  • Did you put any text in the "Public File Name" field?
  • If you did, did you type an extension there?

Here is what I found:

  • When I ran tests where I had that field empty, the uploaded file name with extension was prompted for the download.
  • When I ran tests where I had that field filled with something like "MyDocument.docx", the file name "MyDocument.docx" with extension was prompted for the download.
  • When I ran tests where I had that field filled with something like "MyDocument", the file name "MyDocument" with no extension was prompted for the download.

This is how it is intended to work. Please advise if you have other results.

Hessel
Hessel

Ah my mistake I didn't see the placeholder text. I used "MyDocument" without extension. When I add .pdf tot the Public File Name field the download is correct =)

tim35955
tim35955

I had the same issue. Users never append a file extension or using complete non sense. Maybe you can append this to the plugin? Which simply appends the original file ending, if it is missing in the pub name.

Cheers

components/Download.php:226


        $fileInfo->increaseViewCount();
        $username = $user ? $this->trans('download-comp.user') . $user->id . ' - ' . $user->name . ' ' . $user->surname : $this->trans('download-comp.unknown-visitor');
        $userid = $user ? $user->id : 0;
        Log::add($this->trans('download-comp.log-txt1') . $id . ' - ' . $fileInfo->pubname . $this->trans('download-comp.log-txt2') . $username . '.',
            $userid,
            $fileInfo->id);

        $filename = $fileInfo->pubname;

        $originalFileName = $fileInfo->privatefile->file_name;
        $originalFileEnding = substr($originalFileName, strrpos($originalFileName, "."));

        // if the pubname has a different file ending, append the original one
        if (substr($filename, -strlen($originalFileEnding)) !== $originalFileEnding) {
            $filename .= $originalFileEnding;
        }

        $fileInfo->privatefile->file_name = $filename;
        return $fileInfo->privatefile->output();

Last updated

1-8 of 8