0

I'm building an application where users can upload a short portrait video about themselves for promotion within the community. The keyword being short. I would like to prevent users from being able to upload 1 hour epics.

I have tried figuring out a way to verify this on the client side yet with all the available video formats out there I resolved to doing it server side. This is where I hit the next wall.

I upload the users videos in chunks (due to be expected large files) via a reference directly into my blob storage. Thereafter the files will be copied into another storage linked with an azure media services account.

In-between the upload and the copying to the second storage is where I want to verify the duration. From the libs I have tried (Accord, NReco, MediaToolkit) all have failed in one way or other (Not supporting running in azure websites, not reading from blobs or similar issue).

So I'm kind of stuck at the moment. Does anyone have any ideas how this could be done without having to go through the encoding via azure media services first?

TiGoRn
  • 45
  • 9

1 Answers1

1

I would simply upload to %TEMP% (which expands to d:\local\temp). That's local storage in App Service. All those libs should then work against the local filesystem, including MediaInfo, my personal favorite.

For Standard Tier there seems to be plenty of room, here's what Kudu reports:

d:\local usage: 230,397 MB total; 188,630 MB free

So,

upload file
    |
    |                         too long?
check length with video lib ------------- notify user, cleanup local storage
    |
    | all good?
    | 
async upload to blob storage (Media Services)
    |
async cleanup local storage

Cleanup your %TEMP% with a nightly WebJob to account for stale/incomplete uploads (i.e. remove files older than 6 hours), just in case your delete calls to the filesystem fail from time to time due to unforeseen reasons.

evilSnobu
  • 24,582
  • 8
  • 41
  • 71
  • Thank you for the input. I didn't realize I could use a "local" temp folder as I saw the Web App just as a service. I will definitely give this a try. – TiGoRn May 01 '17 at 06:47
  • I have a small amendment to make, your solution is spot on for single server instance. As for load balanced environments, depending on the upload process, it might not work. Just an info for people having a similar constructs. – TiGoRn May 05 '17 at 06:56
  • 1
    By default you have the `ARRAffinity` cookie enabled in App Service so the client sticks to whatever instance it hit first. Should not be a problem as long as the client sends back cookies. This is independent of the application stack (Node/.NET/whatever) since the routing mechanism lives in the frontend layer. See this for more - https://blogs.msdn.microsoft.com/benjaminperkins/2016/06/03/setting-application-request-routing-arr-affinity-for-your-azure-app-service/ – evilSnobu May 05 '17 at 06:59
  • thanks for the input, I did not realize azure provides this functionality as I'm still quite new to the whole azure environment (but learning something new everyday makes us grow, so good) – TiGoRn May 05 '17 at 15:17