diff src/lib/Shared.luan @ 33:4fdc4ec0050b

upload with uploadcare
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 01 Aug 2022 22:50:16 -0600
parents 3ea49246d6a7
children c8d47981c74f
line wrap: on
line diff
--- a/src/lib/Shared.luan	Fri Jul 29 13:57:20 2022 -0600
+++ b/src/lib/Shared.luan	Mon Aug 01 22:50:16 2022 -0600
@@ -96,4 +96,20 @@
 	end
 end
 
+function Shared.get_url_from_file(file)
+	local url = "https://upload.uploadcare.com/base/"
+	local options = {
+		method = "POST"
+		enctype = "multipart/form-data"
+		parameters = {
+			UPLOADCARE_PUB_KEY = "fe3d30f3088a50941d45"
+			file = file
+		}
+	}
+	local response = uri(url,options).read_text()
+	response = json_parse(response)
+	local code = response.file or error()
+	return "https://ucarecdn.com/"..code.."/"..file.filename
+end
+
 return Shared