Main Menu

Send files over http

Started by Random_TNT, Jul 05, 2022, 06:18 PM

Previous topic - Next topic

Random_TNT

Hey, i wanted to make an app store for my os, i need to know how to send files to my app store server

Erb3

#1
Hey, Welcome to the forums!

To send a file with the http api, you can use something like the following code:
local data = fs.open("fileToSend.lua", "r").readAll()
http.post("http://example.com/appstore/submit_app", "file=" .. data)

I replaced the example URL with a web server, and the result is:

This is the body of the HTTP request.

The first line opens the file in read mode, and reads its contents.
The next line sends a POST request to the URL with the filecontents in the body.

Good luck with your OS, reply with a comment if my code dosent work, or if it works feel free to let me know too 😉.
It's not a data breach, it's a surprise backup.