Upload a video to server

Upload a video to server

  

Apologies in advance for what must be a very basic question, but after several hours of going through the various entries for this subject in the forum, I am still no closer to understanding some basic principle!

I have an entity on the server called Video, and simply wish to populate it with some videos that I have stored on my local hard drive.  This is a one-time thing, I need no menu to control it, I simply wish to upload some files manually.

Could somebody please explain the individual steps needed?  All the attempts I have made so far fail on my not understanding how to put the file location on my hard drive into OutSystems 10 in a format that Systems 10 understands.  An attempt to upload with the Upload widget just left me staring at a blank screen that was not obviously doing anything......


I am sorry that I have not picked up enough from the training exercises to work out how to do this!


Thank you


Graham

Hi Graham,

First, your OutSystems application runs on the Server. The Server is a computer that is connected to your computer and hence browser through the network, but obviously it has no way to access files stored locally on your computer. So unless you can put the files on some shared network server's storage, this is not the route to go.

Secondly, videos are typically enormous (gigabytes of data). You typically do not store them in a database, lest the database becomes full very quickly. If you are trying to put them in the database of a Personal Environment, this will quickly result in it being locked for exceeding storage limits.

Thirdly, as for the Upload widget, it works fine for files that have a decent size (upto a 10s of megabytes), since the entire file is put in your computer's memory, converted to a format the server will understand (also in memory) and send to the server, that needs to handle that in reverse. If you use huge files (like videos), this can quickly become a very slow process as you run out of memory, or the server does (perhaps triggering an IIS recycle or whatnot), so I'm not suprised it doesn't work (unless they are small videos e.g. from a mobile phone).

Of course then there's the question of what you want to do with those videos. You cannot show them in a browser decently if they are stored as a whole in the database, as the browser would need to fetch them in their entirety to be able to display them (as opposed to getting them streamed).

So concluding, it of course all depends on your usecase, but you might as well better abondon this...

Hi Kilian:

Thank you for a comprehensive reply - it is clear now that I should have given more details before!

I am creating a demo of what an app would look like on my client's phone, the better to discuss the specifics of what he wants (very vague at the moment, he is feeling his way).  He is in the property business, and has CCTV in many of them, and wants to be able to select the feed from his cameras for viewing.  So, for the purpose of the demo, all I want to do is upload a couple of short videos, (no more than 20Mb each, for instance), just so that he can see them working in the app.  Come the real thing, he will be tapping into the live cameras, going via a streaming system, so providing URL's ought not be an issue for the app. And we will not be having to store the video on a server or on the phone, he just wants to see the live stuff.

So, given the above, and your comments further above, I would have expected the upload widget to work fine.  Certainly it asks for the name of the file being uploaded (my sample is an .mp4 file, 15Mb), and the correct file name is selectable - and then nothing......

Do you know of any way to trace what is happening, please? (I have yet to look into the debugger, but I am pretty sure it is not going to be applicable in this case....).


Any thoughts gratefully received!


Thank you


Graham


Hi Graham,

The Upload widget itself just loads the file into local memory. To send it to the server, you'll need a Button or Link with type Submit (not Ajax Submit, that won't work because of how the HTTP protocol works). After pressing the Button/Link, the content of the upload will be send to the server. The contents, file name and file MIME type can be accessed via the upload widget's name (default Upload1). In this action you can actually save the content to the database.

Oh, dear, my ignorance is showing!  I have added a button, but can find no way of giving it (or a Link) a type Submit.  And when I access the upload widget, it does not tell me anything other than: 

FileContent:  

GetVideoById.List.Current.Video.FileContent

Filename:

GetVideoById.List.Current.Video.FileName

Accept:   Video


The Button is asking for something to go into the Event On Click field, but I see nothing there that looks like a submit......


I assume that I am missing something obvious?!


Graham


Hi Graham,

It's the Method property:


Note that "Submit" is default.

So, I seem to have a rather different response from my button:


Rather different fields from your example.....

Ok, I think we're not on the same page here... Are you creating a Mobile App? Because in that case there's indeed no Submit (but that's no impediment).

Yes, this is for a mobile app (sorry for not spelling that out earlier).  So does that involve a different approach, please?




No, not really. The main difference is that on Mobile, there's no file type returned (file type is determined by the server, there's several posts about that if you search), so you have to rely on e.g. file extension.

I think I am back to where I started! (ie this is a really basic question!)


The upload widget has put the video into the right format, in memory.  How do I send it from there to the server, please?  On a web site, i would use Submit; what do I use on Mobile? :)

I'm not sure why you would even want the data transferred from the mobile app to the server. You're saying this is a demo, and you need to display some videos in the app - why not store them locally using the local storage?

That said, sending data from an app to the server can be done in various ways:

  1. Explicitly build a REST service for it.
  2. Call a server action (which also invokes an implicit REST action).
  3. Store it locally and then use one of the synchronization patterns to sync with the server.


My apologies for having taken so long to reply, Kilian.  You are absolutely right, it makes total sense to put the videos into Local Storage.


That said, I am still being dumb about a fundamental issue.  I have .mp4 files on my PC hard drive, I don't see any way of uploading them into Outsystems 10 Local Storage.  What principle is it that I am just not seeing, please?


Thank you


Graham (hope that you had a brilliant Christmas and New Year!)

Well, if it's the other way around, that is, you have them on a server and need them locally, there's several things you can do. Since this is a demo app, I'd do the following:

  1. Create an eSpace that exposes a REST API for retrieving videos.
  2. In that eSpace, add the videos as resources (Data tab, at the bottom).
  3. Have the mobile app synchronize with the server in case it doesn't yet have the videos, using the REST API.

Of course, in a production grade app I'd do it differently (we currently have an app that uses streaming to sync large content).

I have this remarkable capacity for making this more difficult than it needs to be!

Given that I am doing a demo, the mobile app is not actually "produced" as an app yet, I am merely running the system in my browser on the PC.  Would I be correct in saying that in such circumstances the local storage is on the PC, since it is the 'device' that the browser is simulating - ie we are not going anywhere near a mobile phone.

So, what I am looking for is a way to make the .mp4 file on the PC available to the Outsystems Local Storage on the PC.

Does that make things clearer, please?


Thank you


Graham 

Yes, it makes things clearer. In that case, I'd create a page to upload the vids. But since you got problems with uploading them before via the upload widget I'm not sure whether it makes it that much easier :).

Kilian, I am sorry to continue to be a numbskull - but this is ignorance of a fundamental principle with Outsystems which I have failed to fathom so far.  I have not been able to find any reference to uploading a video - or any data other than something in an Excel spreadsheet - to the server.  I am sure that it is dead simple - but I have just not found it (and it does not seem to be in any of the exercises).


So, when you say "I'd create a page to upload the vids", I am still unaware of what that means!

As I have been saying all along, this is a very fundamental principle that I have missed somewhere.  I am able to create individual records in an entity, and amend or delete records there - but I do not know how to upload something like a video.

A reference as to where to look would probably suffice!

Thank you


Graham