XFileSharing Pro - Cannot download MP4/WMV after install NGINX!

Message
Author
panda
Posts: 28
Joined: Mar 09, 2012 4:13 am

Cannot download MP4/WMV after install NGINX!

#1 Postby panda » Mar 23, 2012 1:34 pm

My problem is that when clicking the download link of the mp4 or wmv file, the download box is not pop-up to be saved like other file types, but it turns to like a streaming video to watch in the browser.

I still cannot find the solution. Any advice? Thank you so much.

1. With nginx, what settings do I make to disable the streaming?

2. Do I need something to run with nginx?
Last edited by panda on Mar 23, 2012 7:27 pm, edited 3 times in total.

ikky
Posts: 14
Joined: Jan 30, 2012 2:08 pm

#2 Postby ikky » Mar 23, 2012 2:49 pm

If I remember correctly, you need to disable "Generate direct links" in setting/userlimits

panda
Posts: 28
Joined: Mar 09, 2012 4:13 am

#3 Postby panda » Mar 23, 2012 5:00 pm

ikky wrote:If I remember correctly, you need to disable "Generate direct links" in setting/userlimits
Thanks so much. But then we can't resume downloads & multiple connections?

Any advice to solve without the diasable the Generate direct link?

trinsic
Posts: 149
Joined: Dec 21, 2009 9:24 am

#4 Postby trinsic » Mar 24, 2012 1:02 am

Nginx requires you to add the attachment header to all requested files.

Simple version, add this to your config.

Code: Select all

location /files {

        if ($request_filename ~* ^.*?/([^/]*?)$)
        {
                set $filename $1;
                add_header Content-Disposition "attachment; filename=$filename";
        }
}
We're putting the location under files because we want the progress bar to still work on file servers.

We then use Regex to see when a file is requested and if so it'll save it under $1. For ease of use we set $1 to $filename.

Add in your header using $filename.

There are a number of streaming files including mp3, mp4 and pdf so this will force download on them all.

panda
Posts: 28
Joined: Mar 09, 2012 4:13 am

#5 Postby panda » Mar 24, 2012 3:57 am

trinsic wrote:Nginx requires you to add the attachment header to all requested files.

Simple version, add this to your config.

Code: Select all

location /files {

        if ($request_filename ~* ^.*?/([^/]*?)$)
        {
                set $filename $1;
                add_header Content-Disposition "attachment; filename=$filename";
        }
}
We're putting the location under files because we want the progress bar to still work on file servers.

We then use Regex to see when a file is requested and if so it'll save it under $1. For ease of use we set $1 to $filename.

Add in your header using $filename.

There are a number of streaming files including mp3, mp4 and pdf so this will force download on them all.
I've added this code you mentioned to the configure file of nginx at the last. Why it's not working?

Any more suggestions?

trinsic
Posts: 149
Joined: Dec 21, 2009 9:24 am

#6 Postby trinsic » Mar 25, 2012 4:43 am

Remove the MP4 mimetype from the mime.types file in nginx config folder.

Or change it to application/octet-stream.

My mime.types file:

Code: Select all

types {

    text/html					html;

}

stdio
Posts: 65
Joined: Mar 27, 2012 4:05 pm

#7 Postby stdio » Apr 11, 2012 12:26 pm

trinsic,

Mind sharing where do you insert that code? nginx.conf or sites-enabled/conf.file? We seem to have an issue in Google Chrome downloading .mpg files. Download simply doesn't start when download link is clicked, however the file can be downloaded by clicking save link as.

Chrome Developer tools (network) says canceled. A friend of mine tested this with an older version of Google Chrome 12. something and the download works perfectly, but with the latest version it doesn't. Any suggestions?

Thanks!

trinsic
Posts: 149
Joined: Dec 21, 2009 9:24 am

#8 Postby trinsic » Jun 01, 2012 2:45 am

Sorry for late reply, don't have email subscriptions turned on.

The first code is added to your /etc/nginx/sites-enabled/default.conf

Or whatever your config file is called there. The second piece of code is located in the mime.types file under: /etc/nginx/mime.types