local function mpupload(file, contentType) contentType = contentType or "application/octet-stream" local url = "https://tmpfiles.org/api/v1/upload" local mpBoundary = "----MyVeryAwesomeBoundary"..math.random(1,1e9) local h = assert(fs.open(file, "r"), "Unable to open file "..file) local d = h.readAll() h.close() local headers = { ["Content-Type"] = "multipart/form-data; boundary=" .. mpBoundary, } local body = "--" .. mpBoundary .. "\r\n" .. "Content-Disposition: form-data; name=\"file\"; filename=\""..fs.getName(file).."\"\r\n" .. "Content-Type: "..contentType.."\r\n" .. "\r\n" .. d .. "\r\n" .. "--" .. mpBoundary .. "--\r\n" local res = assert(http.post(url, body, headers, true), "Request failed") local d = res.readAll() print(d) end local args = {...} local filename = shell.resolve(assert(args[1], "path to file provided")) local contentType = args[2] mpupload(filename, contentType)