# Upload file

- Operation ID: `uploadFile`
- HTTP method: `POST`
- Path: `/uploader-service/storages/{container}/upload`
- [Human-readable API reference](https://hub.synerise.com/api-reference/asset-management#tag/Uploader/operation/uploadFile)

## Self-contained OpenAPI method

The fenced document below contains this method's documentation and all of its local references. It is self-contained; no category or master specification fetch is required.

```yaml
openapi: 3.0.0
info:
  title: Synerise Public API
  version: 1.9.5
paths:
  /uploader-service/storages/{container}/upload:
    post:
      tags:
        - Uploader
      summary: Upload file
      description: |
        
        Upload a new file to Synerise.

        <strong><span style="color:red">IMPORTANT:</span></strong> Due to technical limitations, the code examples on the right don't include the form data. If you use the examples, remember to add it.

        Example correct cURL request:
        <pre>
        curl --location 'https://api.synerise.com/uploader-service/storages/default/upload' \
        --header 'Authorization: Bearer YOUR_TOKEN' \
        --form 'uploads=@"/Users/currentuser/Downloads/image.png"'
        </pre>


        ---

        **API consumers:** <a href="/api-reference/authorization?tag=Authorization&amp;operationId=userLogin" target="_blank" rel="noopener">Synerise User</a>, <a href="/api-reference/authorization?tag=Authorization&amp;operationId=profileLogin" target="_blank" rel="noopener">Workspace (Business Profile)</a>

        **API key permission required:** `UPLOADER_SERVICE_STORAGE_CREATE`

        **User role permission required:** `assets_explorer: create`
      operationId: uploadFile
      parameters:
        - in: path
          name: container
          description: Name of the container in which the file will be stored
          required: true
          schema:
            type: string
            example: default
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - uploads
              properties:
                uploads:
                  description: File to upload, binary
                  type: string
                  format: binary
            example: form
      responses:
        "200":
          description: File description
          content:
            application/json:
              schema:
                type: object
                properties:
                  result:
                    type: object
                    description: Information about the result
                    properties:
                      files:
                        type: array
                        description: File information
                        items:
                          type: object
                          properties:
                            author:
                              description: Name of the user who uploaded the file
                              type: string
                            canEdit:
                              description: Defines if the file can be edited
                              type: boolean
                            canRemove:
                              description: Defines if the file can be deleted
                              type: boolean
                            created:
                              description: Creation date
                              type: string
                            filename:
                              description: Name of the file
                              type: string
                            id:
                              description: ID of the file
                              type: string
                            uuid:
                              type: string
                              description: UUID of the file, without dashes
                            isStarred:
                              type: boolean
                              description: Informs if the file is starred.
                            mimetype:
                              type: string
                              description: The MIME type of the file.
                              enum:
                                - image/png
                                - image/jpeg
                                - image/jpg
                                - image/gif
                                - video/mp4
                                - application/pdf
                                - application/vnd.openxmlformats-officedocument.wordprocessingml.document
                                - application/vnd.ms-excel
                            path:
                              type: object
                              description: Paths to different versions of the resource. Some MIME types only have `origin`.
                              properties:
                                large:
                                  type: string
                                  description: Path to the large version of the file
                                origin:
                                  type: string
                                  description: Path to the original file
                                thumb:
                                  type: string
                                  description: Path to the thumbnail
                            size:
                              type: number
                              description: Size of the file in bytes
                            storageId:
                              type: string
                              description: Name of the container where the file is stored
                            updated:
                              type: string
                              description: Year of last update
                            url:
                              type: string
                              description: URL of the file
                            user_id:
                              type: number
                              description: ID of the user who uploaded the file
                      storageId:
                        type: string
                        description: Name of the container where the file is stored
      security:
        - JWT: []
        - BasicAuth: []
      x-snr-doc-urls:
        - /api-reference/asset-management#tag/Uploader/operation/uploadFile
      x-codeSamples:
        - lang: cURL
          label: cURL
          source: |-
            curl --request POST \
              --url https://api.synerise.com/uploader-service/storages/default/upload \
              --header 'Authorization: Basic REPLACE_BASIC_AUTH' \
              --header 'content-type: multipart/form-data' \
              --form uploads=string
        - lang: Python
          label: Python
          source: |-
            import http.client

            conn = http.client.HTTPSConnection("api.synerise.com")

            payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"uploads\"\r\n\r\nstring\r\n-----011000010111000001101001--\r\n"

            headers = {
                'Authorization': "Basic REPLACE_BASIC_AUTH",
                'content-type': "multipart/form-data"
                }

            conn.request("POST", "/uploader-service/storages/default/upload", payload, headers)

            res = conn.getresponse()
            data = res.read()

            print(data.decode("utf-8"))
        - lang: JavaScript
          label: JavaScript
          source: |-
            const data = new FormData();
            data.append("uploads", "string");

            const xhr = new XMLHttpRequest();
            xhr.withCredentials = true;

            xhr.addEventListener("readystatechange", function () {
              if (this.readyState === this.DONE) {
                console.log(this.responseText);
              }
            });

            xhr.open("POST", "https://api.synerise.com/uploader-service/storages/default/upload");
            xhr.setRequestHeader("Authorization", "Basic REPLACE_BASIC_AUTH");

            xhr.send(data);
        - lang: Node.js
          label: Node.js
          source: |-
            const http = require("https");

            const options = {
              "method": "POST",
              "hostname": "api.synerise.com",
              "port": null,
              "path": "/uploader-service/storages/default/upload",
              "headers": {
                "Authorization": "Basic REPLACE_BASIC_AUTH"
              }
            };

            const req = http.request(options, function (res) {
              const chunks = [];

              res.on("data", function (chunk) {
                chunks.push(chunk);
              });

              res.on("end", function () {
                const body = Buffer.concat(chunks);
                console.log(body.toString());
              });
            });

            req.write("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"uploads\"\r\n\r\nstring\r\n-----011000010111000001101001--\r\n");
            req.end();
        - lang: PHP
          label: PHP
          source: "<?php


            $request = new HttpRequest();

            $request->setUrl('https://api.synerise.com/uploader-service/storages/default/upload');

            $request->setMethod(HTTP_METH_POST);


            $request->setHeaders([

            \  'Authorization' => 'Basic REPLACE_BASIC_AUTH',

            \  'content-type' => 'multipart/form-data'

            ]);


            $request->setBody('-----011000010111000001101001\r

            Content-Disposition: form-data; name=\"uploads\"\r

            \r

            string\r

            -----011000010111000001101001--\r

            ');


            try {

            \  $response = $request->send();


            \  echo $response->getBody();

            } catch (HttpException $ex) {

            \  echo $ex;

            }"
        - lang: Java
          label: Java
          source: |-
            HttpResponse<String> response = Unirest.post("https://api.synerise.com/uploader-service/storages/default/upload")
              .header("Authorization", "Basic REPLACE_BASIC_AUTH")
              .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"uploads\"\r\n\r\nstring\r\n-----011000010111000001101001--\r\n")
              .asString();
servers:
  - url: https://api.synerise.com
    description: Microsoft Azure EU
  - url: https://api.azu.synerise.com
    description: Microsoft Azure USA
  - url: https://api.geb.synerise.com
    description: Google Cloud Platform
tags:
  - name: Uploader
components:
  securitySchemes:
    JWT:
      type: http
      scheme: bearer
      description: |
        Synerise uses [JSON Web Token (JWT)](https://jwt.io/) as the authorization method.

        The token is generated by the *auth/login* endpoints.

        You need to include it in the `Authorization` header of your requests, with a `Bearer` prefix.


        By default, the token is valid for **one week** (see [workspace settings](https://hub.synerise.com/docs/settings/tool/iam-for-apps/general/#jwt-lifetime)).  
        You can request a refreshed key for the session by using the *auth/refresh* endpoint **before** the current token expires.


        You can verify your JWT signature by using the [public key](https://api.synerise.com/v4/public.pem).


        See Developer Guides on JWT API authentication for:
        - [profiles](https://hub.synerise.com/developers/api/api-authorization/client-login/);
        - [workspaces](https://hub.synerise.com/developers/api/api-authorization/workspace-login/#api-authentication-with-jwt);
        - [users](https://hub.synerise.com/developers/api/api-authorization/user-login/).
    BasicAuth:
      type: http
      scheme: basic
      description: |
        Basic authentication with login (workspace GUID) and password (workspace API key) encoded with Base64 and sent in the `Authorization` header. **Must be enabled in the settings of the API key**.

        <span style="color:red">This is less secure than JWTs.</span> Limit the API key permissions to only those that you need. Consider API key rotation and other security measures.

        You can still use JWTs from the same API key when basic authentication is enabled.

        For details, see ["Workspace authentication"](https://hub.synerise.com/jwt-or-basic/#basic-api-authentication-with-api-keys).
```
