How to get thumbnail of an image in ejabberd - file

I uploaded a image/video on ejabberd server using my client and ejabbered in its response sends a url where that image resides.Now client triggers a request on that url and file download starts.What i want to do is basically first send the client a low quality thumbnail(So that if a video is very large and takes time to download ,in that time client will show that blurred image(As in whats app)).How to create this Thumbnail?Any idea?

It looks to me this is a purely client side protocol. Just have the client passing the download information have a link to thumbnail URL as well.

Related

How to update data on React frontend that are yielded in Flask backend by generator?

When a client hits one of my Flask endpoints, I want to construct a python generator that yields a new image every ~5 seconds and sends the image to the React frontend to be updated.
What is the right way to do this? How can I have React update the displayed image?
Have you considered creating a WebSocket connection between the frontend and backend? The socket can remain open and the server can be configured to send the new image in a time interval. On the frontend, you can store the image URL using React.useState and update it in a function that listens for new messages from the WebSocket.
These may be helpful:
https://flask-socketio.readthedocs.io/en/latest/
https://socket.io/docs/v4/client-api/

How to convert a blob url of audio to normal url for downloading files in react?

I used a voice recorder in my application, the voice data contains a blobUrl, that I want to send that url to server for downloading it, but it is not a normal url. is there any way to convert my blob url of audio to a normal url?
blob:http://localhost:3001/dfafdba3-24f4-4f36-b9d8-13f4d9634acc
this might be what you're looking for:
https://stackoverflow.com/a/71885435/11483674
In summary: you extract the data from your browser's blobUrl, make a file out of that and send it over a request to your backend.

What is the difference between server-side and client-side rendering?

That question has a lot of articles around the web discussing it, but given how recent I am to web dev I think I am missing a few pieces to get the full picture.
My understanding is as follows:
Let us assume we have a Node.js server and we're using express for our web app. Client rendering is when I don't enter a URL in the web browser that creates an HTTP request to my server. Instead, the client requests comes from a JS script(that was loaded from the server initially when I accessed the application using the root route for example: http://localhost:SOME_PORT/). So, let's say my request is to fetch some information about a certain user from a database. Instead of going through the server, the JS script(using AJAX) for example does an XMLHTTPRequest directly to the database(say I trigger this by a button called Fetch) instead of going through my server and then the client(the browser) will get a response and in turn will create an HTML document and render it. As opposed to server-side rendering, where I for example enter a URL in the browser, and the server intercepts the request, and prepares the HTML document along with the data requested(if any) and sends it back in HTML form for the browser to render(hence server-side, no work was done on the client-side but actually displaying the page).
Is this accurate? What am I missing in my understanding of both and when to utilize either style?
Let us assume we have a Node.js server and we're using express for our web app.
It doesn't really matter what software you use on the server, but we'll use that for the example.
Client rendering is when I don't enter a URL in the web browser that creates an HTTP request to my server. Instead, the client requests comes from a JS script (that was loaded from the server initially when I accessed the application using the root route for example: http://localhost:SOME_PORT/).
That would have loaded an HTML document which loaded the JS with a script element. You wouldn't load the script directly.
So, let's say my request is to fetch some information about a certain user from a database. Instead of going through the server, the JS script(using AJAX) for example does an XMLHTTPRequest directly to the database
No. You still make an HTTP request to the HTTP server.
(say I trigger this by a button called Fetch) instead of going through my server and then the client(the browser) will get a response and in turn will create an HTML document and render it.
Ish.
The client already has an HTML document. With client side rendering, the DOM generated from that document is modified (usually with new data requested from the server).
As opposed to server-side rendering, where I for example enter a URL in the browser
To keep the scenario as close to the Client-side rendering example as possible, let's say you click a link instead of entering a URL.
, and the server intercepts the request,
The request is explicitly made to the server, it isn't intercepted. That would imply it was intended for somewhere else.
and prepares the HTML document along with the data requested(if any) and sends it back in HTML form for the browser to render(hence server-side, no work was done on the client-side but actually displaying the page).
Basically.
The short version is:
With server side rendering, a complete HTML document is prepared on the server and delivered to the browser.
With client side rendering, the DOM is manipulated on the client to produce the same document.

Failed to Send error when sharing notes and pics

I have a mirror-api application i'm writing that takes notes, pictures and video from the users timeline and stores them. For some reason every note and picture I take and send to a contact i inserted through mirror has "Failed to Send" posted on the timeline card in glass. The app however still receives the timeline item. Anyone else having this issue?
You need to setup the timeline subscription (https://developers.google.com/glass/v1/reference/subscriptions/insert) with "UPDATE" item included in the "operation" list.
Mirror API will sending POST queries with the shared card info to your callbackURL endpoint. Accordingly your service should return HTTP Status 200 in response.
The endpoint should have HTTPS connection. To solve this - use ngrok (https://ngrok.com/) if you're developing on localhost or Google's subscription proxy (just google it, i can post more than 2 links now)

Sending Image/File/Audio Files to Browser via websockets/http using mongoose

I am using Mongoose library to have a localhost server run in my system.
Now, through HTTP Connection OR Websocket Connection, I want to send files/documents/images/small audio files to the client who is making request to the local host.
Until now i was sending a simple json message via websockets and xml data via http connection to client (Browser) by using these Mongoose APIs
mg_send_data()
mg_websocket_write()
Since Mongoose is being used the whole implementation is in C
Kindly let me know if I can refer to any of the example code if there are any, OR any API documentation of Mongoose which would help me to achieve the above.
Looking forward for valuable responses.
From the github repository you will find :
the API documentation
severals samples that show how to implement websocket and sending MJPEG

Resources