ElijahGlover / Umbraco-S3-Provider

Amazon Web Services S3 IFileSystem provider for Umbraco
46 stars 34 forks source link

Unable to load mp4 videos on Safari #6

Closed mikebull closed 7 years ago

mikebull commented 8 years ago

On one of our sites, we've come across an issue where if we're hosting mp4 files on S3, the file will load fine in Safari with the AWS URL, but not from the VPP we've set up.

After inspecting the response, AWS adds the following line to the header:

Accept-Ranges: bytes

It would seem that Safari has an issue where it looks to load the file in parts, and if it cannot, it won't bother to render the video at all. The video loads fine over the VPP in all other browsers, but Safari on the Mac.

The same issue has been raised for one of the other Umbraco providers that targets Azure, so I've improvised with the following code in FileSystemVirtualPathProviderFile.cs to add the header to the response.

public override Stream Open()
{
    if (HttpContext.Current != null)
    {
        var path = HttpContext
            .Current
            .Request
            .FilePath;

        if (path.Contains("mp4"))
        {
            HttpContext
                .Current
                .Response
                .AppendHeader("Accept-Ranges", "bytes");
        }
    }

    return _stream();
}

With this code in place, we've managed to get mp4's to render. If you're okay with me doing so, I'm happy to add this code in a pull request.

ElijahGlover commented 8 years ago

Happy for you to submit a PR.

ElijahGlover commented 7 years ago

This should be done in web.config and not relying on HttpContext.Current

hamishrouse commented 7 years ago

What needs to be updated in the web.config to allow partial requests for media files (e.g. .mp4, .mp3 etc)

saifobeidat commented 4 years ago

@hamishrouse add this to your web config <add name="Accept-Ranges" value="bytes" />

mari-ikomet commented 3 years ago

Thank you so much. Its working fine