Problem when opening links to media files on Android

Vote:
 

Hello

When linking to media in a XhtmlText field, in this case a pdf file, it works fine on all platforms except for Android.

What happens on Android is that when you choose to open the file in Adobe you get the following error: 

The document cannot be opened because it is not a valid PDF document.

This happens because the file is never downloaded.

If you, instead of choosing to open the file with adobe, choose to open it with the browser it will download fine and you can open it from your downloads folder.

I can workaround this by creating a mediafile pagetype with it's own controller.

In that controller I can set the Content-Disposition header which seem to fix the issue.

But editors still can, and therefore will, put links to mediafiles in the text.

Is there any event or something I can override to set Content-Disposition header when a file in globalassets is requested?

Any other suggestions? 

#145903
Mar 15, 2016 9:50
Vote:
 

I figured out that I can set Content-Disposition using the urlrewrite module using the following configuration:

<outboundRules>
    <rule name="Set content disposition on pdfs" preCondition="FileIsPDF">
        <match serverVariable="RESPONSE_Content-Disposition" pattern=".*" />
        <conditions>
            <add input="{REQUEST_FILENAME}" pattern="(.*)\\([^/]+)\.pdf$" />
        </conditions>
        <action type="Rewrite" value="inline; filename="{C:2}.PDF"" />
    </rule>
    <preConditions>
        <preCondition name="FileIsPDF">
            <add input="{REQUEST_FILENAME}" pattern="\.pdf$" />
        </preCondition>
    </preConditions>
</outboundRules>

That didn't solve the problem though.

#145917
Mar 15, 2016 15:48
Vote:
 

Check that you don't have firewall that strips the response headers. That happened to me once and was not funny at all :)

#145927
Mar 15, 2016 17:02
Vote:
 

Nope, Fiddler tells me that the header is there.

When I link a media file page I return with a FileStreamResult, I wonder how EPi returns the file?

#145929
Mar 15, 2016 17:24
Vote:
 

Problem solved.

As I was trying this on a test website that was auth-locked you needed to login to download the file.

The android browser was of course logged in but when you tried to open (download) the file with Adobe you would get denied.

So no headers or any special treatment necessary, just make sure the file is accessible for the Everyone group.

#146488
Mar 16, 2016 14:25
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.