Request and save file
(Created page with "'''request and save file''' is a command that sends a request to a specified URL and saves the response content to a file. This command is useful when you want to download a...") |
|||
Line 1: | Line 1: | ||
'''request and save file''' is a command that sends a request to a specified URL and saves the response content to a file. | '''request and save file''' is a command that sends a request to a specified URL and saves the response content to a file. | ||
− | This command is useful | + | This command is useful for situations in which an API returns a downloadable file. |
== Parameters == | == Parameters == | ||
Line 11: | Line 11: | ||
'''Method:''' The HTTP method to use for the request. Options include "GET", "POST", "PUT", and "DELETE". | '''Method:''' The HTTP method to use for the request. Options include "GET", "POST", "PUT", and "DELETE". | ||
− | '''Data:''' (optional) The data to send | + | '''Data:''' (optional) The data to send with the request. This should be an object in yaml or json format. |
− | '''Headers:''' (optional) Any headers | + | '''Headers:''' (optional) Any headers that should be sent with the request. This should be an object in yaml or json format. |
== Example == | == Example == | ||
<pre> | <pre> | ||
− | request and save file("https:// | + | ui console view |
+ | request and save file("https://placekitten.com/200/300","C:\\Users\\Documents\\cat.png","GET","","") | ||
+ | log image("C:\\Users\\Documents\\cat.png",50) | ||
</pre> | </pre> | ||
− | The script above sends a "GET" request to the specified URL. The response, which is expected to be a file, is saved to "C: | + | The script above sends a "GET" request to the specified URL. The response, which is expected to be a file, is saved to "C:\Users\Documents\cat.png". It then displays the image in the console. |
− | + | ||
− | + | ||
− | + | ||
− | + |
Latest revision as of 14:15, 13 July 2023
request and save file is a command that sends a request to a specified URL and saves the response content to a file.
This command is useful for situations in which an API returns a downloadable file.
[edit] Parameters
URL: The URL from which the file should be downloaded.
File Name: The name and path under which the downloaded file should be saved.
Method: The HTTP method to use for the request. Options include "GET", "POST", "PUT", and "DELETE".
Data: (optional) The data to send with the request. This should be an object in yaml or json format.
Headers: (optional) Any headers that should be sent with the request. This should be an object in yaml or json format.
[edit] Example
ui console view request and save file("https://placekitten.com/200/300","C:\\Users\\Documents\\cat.png","GET","","") log image("C:\\Users\\Documents\\cat.png",50)
The script above sends a "GET" request to the specified URL. The response, which is expected to be a file, is saved to "C:\Users\Documents\cat.png". It then displays the image in the console.