comparison src/lib/Shared.luan @ 34:c8d47981c74f

upload using ajax
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 02 Aug 2022 20:46:02 -0600
parents 4fdc4ec0050b
children 0c1b820fff34
comparison
equal deleted inserted replaced
33:4fdc4ec0050b 34:c8d47981c74f
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
115 return Shared 99 return Shared