Erlkonig Posted May 21, 2021 Share Posted May 21, 2021 I have no idea how can I do this, had tried something but nothing happens. I want to send the file via fetchRemote using multipart/form-data. Have someone experience in this stuff? Link to comment
Scripting Moderators Sarrum Posted May 21, 2021 Scripting Moderators Share Posted May 21, 2021 . I can share an example of how to do this using the Imgur API. local file = fileOpen ( "image.png", true ) local data = fileRead ( file, fileGetSize ( file ) ) data = base64Encode ( data ) fileClose ( file ) local sendOptions = { method = "POST", headers = { [ "Authorization" ] = "Client-ID <YOUR_CLIENT_ID>", -- replace <YOUR_CLIENT_ID> with your client ID [ "Content-Type" ] = "multipart/form-data" }, formFields = { [ "image" ] = data, [ "type" ] = "base64" } } fetchRemote ( "https://api.imgur.com/3/upload", sendOptions, function ( data, info ) iprint ( data, info ) end ) The image file (image.png) should be located in the resource folder. 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now