Upload camera video feed to flask rest api - python

I am trying to deploy a realtime image recognition system in python flask api then call it in a winform desktop application, what's the best way to send the video feed throug a json format.

You can send via base64 format inside json. But best way is designing flask api to expect multipart form data.Even json data + multipart is possible.

Related

How to send image between React Native and Flask?

I have a React Native app where I want to send an image to my Flask backend to do some image processing (annotations) then return this new image back to React Native to display it.
I spent a whole day trying to figure this out but was unsuccessful. Does anyone have any ideas on how to achieve this?
I plan on using Firebase's storage system to store these images so I wouldn't mind using that either if that makes things easier.
What I've tried so far is sending the image uri to Flask and read the image file and was able to do the image processing however I couldn't figure out how to send the new image back to React Native...
How are you sending the image to Flask right now?
Typically you could implement an async function on RN that awaits a response.
In plain English:
A function that uploads an image to the back end and awaits for the image to be processed.
Expects in return a URL of the image on the back-end (or Firestore).

WSO2 api manager not sending uploaded multiple files to backend server

I have built a python webservices application using flask.
After creation of swagger document, I published the api in WSO2 API manager.
The publish of API and subscription to the API are successful.
I am able to get authentication token as well.
What I am doing
To consume the API, in Postman/Angular application I am uploading 2 excel file
Files are then sent to WSO2 server url which then sends it to python server
When python server receives the file, it parses it.
Does some calculations and returns the response data object.
Now the problem is at step 3. The files received at Python end are not in the excel format. The data of both the file are combined into one FileStorage object.
Please see the snapshot below
Instead of two One FileStorage object received in request.files
I am trying this all in postman as well as with an angular application and both doesn't work.
I even tried it via swagger at published app's page in WSO2 API manager but that also doesn't works.
Sending Files Via WSO2 Swagger
What only works
When I try the Swagger of published app, Or when I consume the services via postman making a request directly to python's server.
I am getting both the files in proper required format.
File received properly when tried with python app's swagger page
Can you please help me to understand as to what I might be doing wrong.
I am using content type as below
'content-type: multipart/form-data;
After some digging up I found my resolution at Multipart form data file upload using WSO2 API manager?
I added the
<messageBuilder contentType="multipart/form-data"
class="org.wso2.carbon.relay.BinaryRelayBuilder"/>
<messageFormatter contentType="multipart/form-data"
class="org.wso2.carbon.relay.ExpandingMessageFormatter"/>
inside the JSON Message Builders and JSON Message Formatters section in axis2.xml file at
<API-M_HOME>repository\conf\axis2\axis2.xml

Get JSON format from adwords api report

So I'm building an application which has a frontend in React and a backend
in python (pyramid framework).
I recently integrated the google adwords api to query custom reports (doing this in python).
I'm able to get a report from the api by making a query.
However, the response comes either in xml or csv format. The api doesn't support json response at the moment.
My question is: how can I get the data to json format and send it back to my frontend so I can display it in my webapp?

Can I upload a file to GCS from Google Endpoints?

I'm trying to upload a file from API Rest (Google Endpoints) to GCS, but I have retrieve a lot of errors. I don't know if I'm using a bad way or simply Google Endpoints does not upload a file.
I'm trying who my customers upload files to my project bucket.
I read "Endpoints doesn't accept the multipart/form-data encoding so you can't upload the image directly to Endpoints".
Mike answered me at this post but dont know how to implement that on my project.
I'm using this libray (Python):
https://cloud.google.com/appengine/docs/python/googlecloudstorageclient/
If is possible, whats the better way? Any example?
Thanks so much.
I think what Mike means in the previous post, is that you should use Blobstore API to upload file to GCS, instead of using endpoints, and take the data again to the blobstore.
But that will depends on what platform is your client. If you use Web-based client, you should use ordinary way just as Mike has explained (by using HTML form and handler). But if you use Android or mobile client, you can use GCS Client library or GCS REST API.

Uploading to Blobstore without using blobstore.create_upload_url

I would like to create an app using python on google app engine to handle file upload and store them into the blobstore.
However, currently blobstore requires the use of blobstore.create_upload_url to create the url for the file upload form post. Since I am uploading from another server, my question is, is it possible to upload file to gae blobstore without using that dynamic url from blobstore.create_upload_url?
FYI, it is ok that I request a upload URL from the python script before I upload from another server but this creates extra latency and that is not what I want. Also I read that using the so called "file-like API" from http://code.google.com/intl/en/appengine/docs/python/blobstore/overview.html#Writing_Files_to_the_Blobstore but the documentation didn't seem to cover the part on uploading.
Also, previously I tried to use datastore for file upload, but the max file size is 1MB which is not enough for my case. Please kindly advise, thanks.
There are exactly two ways to write files to the blobstore: 1) using create_upload_url, and posting a form with a file attachment to it, 2) writing to the blobstore directly using an API (with a solution here for large files).
If you want a remote server to be able to upload, you have the same two choices:
1) The remote server firsts requests a URL. You have a handler that's just is only to return such a URL. With this URL, the remote server crafts a properly-encoded POST message and posts it to the URL.
2) You send the file data as an HTTP parameter to a handler to your app engine server, which uses the blobstore write API to then write the file directly. Request size is limited to 32MB, so the maximum file size you can write using this method will be slightly under that.

Categories