Access to videos over 5M

Hello,

I have a .NET6 application running on AWS Linux AMI 2
https://docs.servicestack.net/deploy-netcore-to-amazon-linux-2-ami

If I publish a video (over 5M) as a static file, it is working
https://mds.mojomotorcycles.com.au/Content/images/xxx.mp4

I have 3S buckets (not set public), I use this code in the AppHost.Configure

var s3Client = new AmazonS3Client();
this.InsertVirtualFileSources.Add(new S3VirtualFiles(s3Client, Constants.StorageAccountName));

All good and it is working for many files: PDF, Images etc (even large like 60Mb)

Now I have an issue with Videos ONLY (.mp4 or .mov) when above around 5Mb

The above video that works as a static file published as content, is not working via the Virtual File System as:
https://mds.mojomotorcycles.com.au/transaction-videos/xxx.mp4

Other videos < 5M like this one about 3M are working
https://mds.mojomotorcycles.com.au/transaction-videos/xxx.mp4

So that seems to have to do with the Virtual File System, for only video above 5M. Does that ring a bell for you?

Thank you
Thierry

This is just a wrapper around S3 APIs, it doesn’t impose any additional limits itself, do you have any StackTrace or HTTP Error Responses that shows why it’s failed?

ok, I have an error:
Sending Range Responses requires a seekable stream eg. FileStream or MemoryStream

Looks like above 5M the browser wants a stream

ServiceStack.Host.Handlers.StaticFileHandler: Error: Static file /transaction-videos/8b1e8238-72d9-498e-a65c-37ede6f7e668.mp4 forbidden: Sending Range Responses requires a seekable stream eg. FileStream or MemoryStream
ServiceStack.HttpExtensions: Error: Error executing async afterHeaders: Exception of type 'ServiceStack.Host.HttpException' was thrown.

ServiceStack.Host.HttpException: Exception of type 'ServiceStack.Host.HttpException' was thrown.
   at ServiceStack.Host.Handlers.StaticFileHandler.<>c__DisplayClass39_0.<<ProcessRequestAsync>b__0>d.MoveNext() in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack\Host\Handlers\StaticFileHandler.cs:line 291
--- End of stack trace from previous location ---
   at ServiceStack.HttpExtensions.EndHttpHandlerRequestAsync(IResponse httpRes, Boolean skipHeaders, Boolean skipClose, Func`2 afterHeaders) in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack\HttpExtensions.cs:line 140
Microsoft.AspNetCore.Server.Kestrel: Error: Connection id "0HMFH132VKF0F", Request id "0HMFH132VKF0F:00000002": An unhandled exception was thrown by the application.

System.InvalidOperationException: Response Content-Length mismatch: too few bytes written (0 of 24093).

Yeah the issue is that the browser is requesting a HTTP Range request, but the ResponseStream returned by S3’s GetObject() API isn’t seekable:

It looks like there’s a way to support HTTP Range Requests using S3 SDK ByteRange request but it will require breaking out of the Stream abstraction and implementing new APIs on all VFS providers which will take a while.

If you can add it as a feature request, we’ll look into adding support for it:

https://servicestack.net/ideas

Got it, thank you. I added the feature request.
So for now, I should set my S3 Bucket with public access as a workaround

1 Like

I’ve extended IVirtualFiles with WritePartialToAsync and added custom support for S3 in this commit so you should now be able to return partial HTTP Range requests from a S3 Virtual FIle.

This change is now available from v6.0.3 that’s now available on MyGet.

1 Like

@mythz thank you!
I can confirm it is working, and I can stream large videos via the S3 Virtual FileSystem :+1:

2 Likes