Discussions

Ask a Question
Back to All

Application Document Upload Mimetype

Hej there,

we're trying to upload some documents to the application api and always getting the problem, that the files inside the personio backend does'nt get a correct preview neither can be downloaded correctly.

It seems that the mimetype of the uploaded files get lost, so it's always "text/plain".

We're using PHP with guzzle to request the api and having a nearly similar code like the api documentation example:

<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.personio.de/v1/recruiting/applications/documents', [
  'multipart' => [
    [
        'name' => 'file',
        'filename' => 'gitlab-icon-rgb.png',
        'contents' => 'data:image/png;name=gitlab-icon-rgb.png;base64,iVBORw0KGgoAAAANSUhEUg....',
        'headers' => [
                'Content-Type' => 'image/png'
        ]
    ]
  ]
  'headers' => [
    'Accept' => 'application/json',
    'Authorization' => 'Bearer XXX',
    'X-Company-ID' => 'XXX',
  ],
]);

echo $response->getBody();
``

When sending this autogenerated code to the api, I'm getting the following result:

{
"extension": "txt",
"mimetype": "text/plain",
"original_filename": "gitlab-icon-rgb.png",
"uuid": "f198a250-c093-4d07-bbc0-8e9b0cbdf05f",
"size": 21187
}


So the api is detecting a "text/plain" mimetype, but I was uploading a "image/png" mimetype. What is wrong with the request?