Informacje

Uwierzytelnianie wymagane
Format odpowiedzi json
Metoda HTTP POST

POST temporary_files

Ostatnia modyfikacja 2026-05-18 13:56:05

Tworzy na serwerze tymczasowy plik dostępny przez 24 godziny. Zwrócony token jest używany np. przy dodawaniu załączników do zgłoszenia.

URL

https://your-system-name.thulium.com/api/temporary_files

Parametry

filename

wymagany

Nazwa pliku. Przykładowa wartość: file.txt

Przykładowy request

POST https://your-system-name.thulium.com/api/temporary_files?filename=file.txt
Dane file content

Przykładowy response

{"filename":"file.txt","token":"180174033853be57b76ed6a","size":12}

Przykładowe wywołanie


PHP
<?php
$data = 'file content';

$request = curl_init('https://your-system-name.thulium.com/api/temporary_files?filename=file.txt');
curl_setopt($request, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/octet-stream',
    'Content-Length: ' . mb_strlen($data)
));
curl_setopt($request, CURLOPT_USERPWD, 'api_user:api_pass');
curl_setopt($request, CURLOPT_TIMEOUT, 30);
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
curl_setopt($request, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($request, CURLOPT_POSTFIELDS, $data);

$response = curl_exec($request);
if ($response) {
    $httpCode = curl_getinfo($request, CURLINFO_HTTP_CODE);
    if ($httpCode == 200){
        print_r(json_decode($response));
    } else {
        echo $response;
    }
} else {
    trigger_error(curl_error($request), E_USER_WARNING);
}

curl_close($request);
JAVA
public class Example {
    public static void main(String[] args) throws Exception {
        ThuliumRestClient restClient = new ThuliumRestClient("api_user", "api_pass", true);

        ThuliumRestClient.ThuliumRestResponse response = restClient.postRawData("https://your-system-name.thulium.com/api/temporary_files?filename=file.txt", new ByteArrayInputStream("content".getBytes(StandardCharsets.UTF_8)));
        System.out.println(response);
    }
}

CURL
curl -u api_user:api_pass -k -X POST -H "Content-type: application/octet-stream" --data-binary @file.png "https://your-system-name.thulium.com/api/temporary_files?filename=file.txt"

HTTPie
http -a api_user:api_pass POST https://your-system-name.thulium.com/api/temporary_files filename==file.txt Content-type:application/octet-stream @file.png