Skip to main content

Create a File

POST/v2/files
API version
v2
Request method
POST
Operation ID
file-create-file

Request​

Responses​

Format
application/json
Description

Created

  • friendlyURLstringdeprecatedrequired

    deprecated, see friendlyUrl

  • friendlyUrlstringrequired
  • idstring (uuid)required
  • mimeTypestringrequired
  • namestringrequired
  • shortIdstringrequired
  • sizeInBytesinteger (int64)required
  • typestringdeprecatedrequired

    deprecated, see mimeType

Content-Type: application/json

{
"friendlyUrl": "3fa85f64-5717-4562-b3fc-2c963f66afa6/me.jpeg",
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"mimeType": "image/jpeg",
"name": "me.jpeg",
"shortId": "file-123456",
"sizeInBytes": 300
}
{
"properties": {
"friendlyURL": {
"deprecated": true,
"description": "deprecated, see friendlyUrl",
"example": "3fa85f64-5717-4562-b3fc-2c963f66afa6/me.jpeg",
"type": "string"
},
"friendlyUrl": {
"example": "3fa85f64-5717-4562-b3fc-2c963f66afa6/me.jpeg",
"type": "string"
},
"id": {
"example": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"format": "uuid",
"type": "string"
},
"mimeType": {
"example": "image/jpeg",
"type": "string"
},
"name": {
"example": "me.jpeg",
"type": "string"
},
"shortId": {
"example": "file-123456",
"type": "string"
},
"sizeInBytes": {
"example": 300,
"format": "int64",
"type": "integer"
},
"type": {
"deprecated": true,
"description": "deprecated, see mimeType",
"example": "image/jpeg",
"type": "string"
}
},
"required": [
"id",
"name",
"type",
"friendlyURL",
"friendlyUrl",
"sizeInBytes",
"mimeType",
"shortId"
],
"type": "object"
}

Usage examples​

$ curl \
--fail \
--location \
-X POST \
-H "Authorization: Bearer $MITTWALD_API_TOKEN" \
-F "file=[Binary Example]" \
https://api.mittwald.de/v2/files
import { MittwaldAPIV2Client } from "@mittwald/api-client";
import { assertStatus } from "@mittwald/api-client-commons";

const client = MittwaldAPIClient.newWithToken(process.env.MITTWALD_API_TOKEN);
const response = await client.file.createFile({});

assertStatus(response, 201);

use \Mittwald\ApiClient\Generated\V2\Clients\File\CreateFile\CreateFileRequest;

$client = MittwaldAPIClient::newWithToken(getenv('MITTWALD_API_TOKEN'));

$request = (new CreateFileRequest());
$response = $client->file()->createFile($request);

var_dump($response->getBody();

On this page