Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- local filePath = "testsound.mp3"
- local url = "https://remote.craftos-pc.cc/music/upload"
- -- mp3 name request
- print("Please enter the name of your mp3")
- local filePath = read()
- if not filePath:lower():match("%.mp3$") then
- filePath = filePath .. ".mp3"
- end
- -- Open the file in binary mode
- local file = fs.open(filePath, "rb")
- if not file then
- print("Failed to open file: " .. filePath)
- return
- end
- local fileData = file.readAll()
- file.close()
- -- Perform HTTP POST request
- local response = http.post(url, fileData, {
- ["Content-Type"] = "application/octet-stream",
- ["Content-Length"] = tostring(#fileData)
- })
- -- Handle response
- if response then
- local result = response.readAll()
- response.close()
- else
- print("Upload failed.")
- end
- print(result)
Advertisement
Add Comment
Please, Sign In to add comment