Upload new medias using the form. or programmatically with PHP:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://domain.tld/add/');
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, [
'some_file' => curl_file_create('/path/to/some/file.jpg'),
'other_file' => curl_file_create('/path/to/some/other/file.png')
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HTTPHEADER,[
'Accept: application/json'
]);
$json_string=curl_exec($ch);
curl_close($ch);
print_r(json_decode($json_string, JSON_OBJECT_AS_ARRAY));
Or with Python:
import requests
with open('/path/to/some/file.jpg', 'rb') as f:
r = requests.post('http://domain.tld/add/', files={"file1":f}, headers={"Accept":"application/json"})
print(r.text)
Typical response data:
Array
(
[0] => Array
(
[sha1] => c4a08279e801ca7459542da745fe4bbd067512b1
[md5] => 94bb595c8b04fb3375fa264bec26ed7b
[size] => 208378
[extension] => jpg
[mime] => image/jpeg
[height] => 1600
[width] => 896
[path] => upload/c4/c4a08279e801ca7459542da745fe4bbd067512b1/file.jpg
[original_name] => file.jpg
[metas_path] => upload/c4/c4a08279e801ca7459542da745fe4bbd067512b1/metas.json
)
[1] => Array
(
[sha1] => edcf7a075f85e038fb6a25f9889577b68dde6a7d
[md5] => 5f618f5859dd3ff64cef280e1b80cbe7
[size] => 1524297
[extension] => png
[mime] => image/png
[height] => 1013
[width] => 1200
[path] => upload/ed/edcf7a075f85e038fb6a25f9889577b68dde6a7d/file.png
[original_name] => file.png
[metas_path] => upload/ed/edcf7a075f85e038fb6a25f9889577b68dde6a7d/metas.json
)
)