comparison 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
comparison
equal deleted inserted replaced
32:72a1b77b4548 33:4fdc4ec0050b
94 else 94 else
95 return {input} 95 return {input}
96 end 96 end
97 end 97 end
98 98
99 function Shared.get_url_from_file(file)
100 local url = "https://upload.uploadcare.com/base/"
101 local options = {
102 method = "POST"
103 enctype = "multipart/form-data"
104 parameters = {
105 UPLOADCARE_PUB_KEY = "fe3d30f3088a50941d45"
106 file = file
107 }
108 }
109 local response = uri(url,options).read_text()
110 response = json_parse(response)
111 local code = response.file or error()
112 return "https://ucarecdn.com/"..code.."/"..file.filename
113 end
114
99 return Shared 115 return Shared