How to send file contents in GET request - file

My robot has a web-based Lua IDE, and now I send the script contents with a GET request, Base64 Encoded. But for some reason, my server sometimes only decodes a part of the file, and sometimes it works just fine with a way longer file. I've written the server myself in C++ (it's on GitHub
), and it uses libmicrohttpd
Is there a more reliable way of sending files through a HTTP request than the method I'm using right now?

Related

How GET process works in http server of MHC(MPLABĀ® Harmony Configurator)

I've tried to make http server with FatFS file system referring to web_server_sdcard_fatfs(https://github.com/GravitasCapstone/pic32-ethernet-sd/tree/master/web_server_sdcard_fatfs/firmware/src).
The problem is that i can't understand the process from receive request to send response.
The sample code doesn't contain file sending units. Then i guess how GET process works in http server. Figure shows the process that I guess.
Firstly, Web browser send GET request with url including valiables (url parameters).
Secondly, The request is reached the web server and the url parameters are stored in the connection data buffer.
Thirdly, File that linked to http requested file (index.html in this case) is automatically searched.
Fourth, The searched directly for these files is mounted by SYS_FS_Mount() function written in app.c.
Fifth, Response message consisted of http header and html body is automatically generated and send,and if the dynamic variables (inside a pair of tilde (~) ) are exists in html file, TCPIP_HTTP_Print fuunctions are automatically called and executed to replace the valiables.
Sixth, TCPIP_HTTP_GetExecute function is automatically called when received GET request.
The role of this function is not send requested file (index.html is automatically send by step 3,4 and 5 in this case).This function is implemented for analyze valiables and control output by the following the valiables.
Could someone please check my guess?
Thank you in advance.

Extracting zipped images from utf-8 encoded reponse of a rest api call and displaying those images to user in react without downloading

I have a zipped file containing images which I am sending as response to a python REST API call. I want to create a rest application which consumes the python rest api in this manner: The response's content should be extracted without downloading (in browser side) and all the images should be displayed to the user. Is this possible? If yes, could you please help me in the implementation? I am unable to find help anywhere.
I think what you are trying to do is have a backend server (python) where zip files of images are hosted. You need to create an application (that could be in react) that
Send HTTP calls to the server get those .zip files.
Unzip them. How to unzip file on javascript
Display the images to the user. https://medium.com/better-programming/how-to-display-images-in-react-dfe22a66d5e7
I'm not sure what utf-8 has to do with this, but this is possible. A quick google gave me the results above.

The name of a created PDF is not transferred from the server to the client (GWT - GAE)

I develope a GWT-application which creates a PDF-file at the server, and then transferres it to the client.
At the client-side, a window appears which allows the user either to
open it with a program assigned to the file name ending, or
save it to disc.
I have read several threads to this topic, such as
How can a user download a file in client side (Google Web Toolkit)
GWT: Showing PDF created as POST response
How can a user download a file in client side (Google Web Toolkit)
and that helped me coding the doGet()-methode in my print-servlet like this:
resp.setContentType("application/octet-stream");
resp.setHeader("Content-Disposition:", "attachment; filename=\"" + fileName + "\"");
This works fine when testing and debugging using the local GWT-developement server.
But my big problem is:
After deploying to GAE and running the code on GAE, the created pdf-name is not transferred to the client...!
Instead of e.g. TestPdf-25072016.pdf, the name only consists of the word print.
This leads to the fact that the standard-program for a PDF is not invoked automatically when I want to open it. And, of course, print is not the name of the PDF I want to have...
Where is my failure? Especially I am confused that everything works fine when using the local developement server?
Thanks a lot for your support!
You could use a tool like Wireshark or Fiddler to capture the actual HTTP header sent to you when you call printing in GAE.
Maybe GAE is adjusting the header or just blocking it.

sending file from client to http server in c programming

i have to write c program in which the file can be transfer to server , we have the http url link for that.what we have to do for sending and receiving file/data.
Actually i have to send file to http server , on calling url the file will be transfer.it's like that when user click on send the text file will transfer to that server. help so some light ..any link that i can get help .thanking you
From reading the comments, it sounds like you're going in the direction of using sockets directly. Don't do that. Use an HTTP client library. The basic HTTP protocol is simple enough that the sockets approach is workable for a rudimentary client, but you won't support features like HTTP keepalives, proxy servers, encryption (https), HTTP/1.1, compression, chunked encoding, or 100 continue without completely reinventing the wheel.
Use libcURL. When writing in C, uploading a file to an HTTP server is only a few dozen lines of code, including boilerplate.

Write files to the Blobstore

Objective: Suppose the client submits a string or text file to the server (Google App Engine) using a web form. I want the server to modify the original file and serve it back to the client.
I think the only way to serve files from GAE is using the Blobstore, right? Then, as we cannot modify blobs, I believe a solution would be:
Client uploads a file using HttpRequest
Server reads the uploaded file and copies it to a temp buffer (not sure if is there a method to do this)
Server deletes original blob
Server modifies data in the temp buffer
Server writes the modified buffer to the Blobstore
Server serves the new blob to the client
Would this work? Could you think about any other solution?
Thanks
I think the only way to serve files from GAE is using the Blobstore, right?
Wrong. A 'file' is just a way of storing data on disk; there's nothing about serving them from a webserver that requires the data come from an actual, writable disk file. You can simply accept the user's data via a form upload, modify it, and serve it back to them, without it having to ever touch disk, the blobstore, or any other permanent storage medium.
This only becomes a problem if the user's data is too large to fit in memory, in which case you will have to store the data somewhere while you work on it, such as in the blobstore.
http://code.google.com/appengine/kb/java.html#fileforms
shows you how to do it for file upload, which has to be performed thro multipart form-data.
Similarly for non-file data, where you read straight from the request stream.
You don't even have to store the file/input stream. Just spit out the processed data into the output response stream, while reading the input FileItemStream or request inputstream.
If your file/input processing requires look-forward, determine the maximum distance of look-forward and use that distance as your buffer size.
Further Edits
To respond to the client with a file type, set the response content-type or mime-type.
e.g., I've had apps which dynamically generated gifs, jpgs, xls, cvs, etc.
There isn't any difference whether source of response stream is a file you read or a stream that you generate dynamically. Because, even if you had a stored file that needs to be sent as response to client, you could still have to convert it into a response stream and flag the content-type appropriately.
For dynamically generated content, unless you need to cache the output, you need not generate the file into a web URL-visible location and then generate a new html page with the link, and send that html page to the browser. You don't need the user's browser to have to refresh itself just to get that link.
You would simply send the "file" directly with the response stream. You could design your GWT client to accept the "file", perhaps in a named frame, where the named frame src url is the app that performs the dynamic generation of the file.
Read http://en.wikipedia.org/wiki/Mime-type to find the content-type you need.
If the target client's browser does not have the content handler set-up for the response's content-type, it would as for a treatment or be treated as a file download.
I had frequently used jsp or jspx to generate dynamically generated charts or spreadsheets. No stored files involved. The response is written to while the request is being read. Let's look at the jsp page directive to set the content-type to invoke MS Excel on a CSV.
<%# page language="java" contentType="application/vnd-ms-excel; charset=UTF-8"
pageEncoding="UTF-8"%>
For a servlet, ServletResponse.setContentType(String)
is method to set the content-type.

Resources