AMI UI: upload movie directly to a Version

I am working on an AMI UI, where I would like to browse the filesystem, select a movie, and upload said movie directly to a Flow Version, instead of upload it first to the AMI web server and then to the Flow Version. Then I’d like to display the name of the Version just created on the AMI UI.
Any idea if that is even possible?

It is possible. What kind of tips do you need? What do you use for the UI, PySide?

Since the AMI is a web application, I am using HTML/JS, and therefore the web browser’s native file browser strips the full pathname from the chosen file.

I believe you can possibly do this with the REST api since you need to request an upload url.

Wouldn’t you simply use the FPT REST API to upload the file you get from your form element? in this case nothing would go through your frontend, you simply get the file and upload it?

I looked at the Python sample implementation that is included in the REST API docs, REST_upload_download_sample.py · GitHub, and I see the that the file to be uploaded has a “./” (dot-slash) as pathname.
Whether the form is ‘application/x-www-form-urlencoded’ or ‘multipart/form-data’ the information regarding the file is without any pathname, and in case the form is ‘multipart/form-data’, the file gets uploaded to the AMI web server first.

I am sure I am missing something important here.

If it helps to make things clearer, my test AMI web server is running Flask, with a HTML/JS front-end. For all the existing Flask routes I am using Flow’s Python API to query existing entities, and/or create new ones.
The feature I am working on is the uploading of a media file to an existing version. If I use a form with an input type="file" name="payload" that file gets uploaded to the AMI web server first, then if I save it to the filesystem, I can upload it to the Version using the Python API.

My initial question was, can the double upload be avoided somehow?

After reading a bit about the REST API, I’m still not clear how can I go from a HTML form submission, to the REST API upload without having the media asset already saved.

As far as my knwoledge here goes is that you’d need to do the upload logic with javascript so you are uploading the file from the user’s local machine to the url endpoint that you request from the rest api.

i.e. you actually run local javascript that does a PUT request to a presigned upload URL provided by the REST api.