> ## Documentation Index
> Fetch the complete documentation index at: https://docs.datalinks.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Prepare multipart upload

> Initiate a multipart upload and get presigned URLs for all parts.



## OpenAPI

````yaml /api-reference/openapi.yml post /upload/multipart/{username}/{namespace}/{datasetName}/prepare
openapi: 3.0.3
info:
  title: DataLinks
  version: 2.2.3
servers:
  - url: https://api.datalinks.com/api/v1
    description: production server
security:
  - bearerAuth: []
  - openId:
      - implicit
paths:
  /upload/multipart/{username}/{namespace}/{datasetName}/prepare:
    post:
      tags:
        - multipart-upload
      summary: Prepare multipart upload
      description: Initiate a multipart upload and get presigned URLs for all parts.
      operationId: prepareMultipartUpload
      parameters:
        - name: username
          in: path
          description: The username associated with the request.
          required: true
          schema:
            type: string
        - name: namespace
          in: path
          description: Namespace for the dataset.
          required: true
          schema:
            type: string
          example: cinematography
        - name: datasetName
          in: path
          description: Name of the dataset.
          required: true
          schema:
            type: string
          examples:
            movies:
              summary: Movies
              value: movies
            actors:
              summary: Actors
              value: actors
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PrepareMultipartRequest'
        required: true
      responses:
        '200':
          description: Returns multipart upload details, including presigned URLs.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PrepareMultipartResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          description: Failed to prepare the multipart upload.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    PrepareMultipartRequest:
      required:
        - filename
        - size
      type: object
      properties:
        filename:
          type: string
          description: Name of the file being uploaded.
          example: large-data.csv
        size:
          type: integer
          description: Size of the file in bytes.
          format: int64
          example: 73473457
    PrepareMultipartResponse:
      required:
        - key
        - partSize
        - presignedUrls
        - uploadId
      type: object
      properties:
        uploadId:
          type: string
          description: Unique identifier for the multipart upload session.
          example: >-
            2~VmxqYXRlRDZWfjJrRWRiZ2FEQXk3dHI4DGhGLygtTmQNXEZPQXFzMVZOZTUgdEdrXCEyNStkQUp3U3Q2RjJqSkV4MFNBOWxJCk0yIHEkfcQ
        key:
          type: string
          description: Generated S3 object key.
          example: uploads/data/20240301-143022-uuid.json
        partSize:
          type: integer
          description: Size of each part in bytes (8MB).
          format: int64
          example: 8388608
        presignedUrls:
          maxItems: 10000
          minItems: 1
          type: array
          description: Array of presigned URLs for multipart upload.
          items:
            $ref: '#/components/schemas/PresignedUrlItem'
    ErrorResponse:
      required:
        - error_code
        - message
      type: object
      properties:
        error_code:
          type: string
          example: UNAUTHORIZED
        error_message:
          type: string
          example: ''
        message:
          type: string
          example: Missing authentication token
        sub_errors:
          type: array
          items:
            required:
              - code
              - message
            type: object
            properties:
              code:
                type: string
              message:
                type: string
    PresignedUrlItem:
      required:
        - size
        - url
      type: object
      properties:
        url:
          type: string
          description: Presigned URL for uploading this part.
          example: >-
            https://my-data-bucket.s3.amazonaws.com/uploads/data/20240301-143022-uuid.json?partNumber=1&uploadId=...
        size:
          type: integer
          description: >-
            Exact number of bytes to upload to this URL. Use this value to slice
            the file — the last part will be smaller than partSize when the file
            size is not a multiple of partSize.
          format: int64
          example: 8388608
  responses:
    BadRequest:
      description: Bad request. The request was malformed or invalid.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: >-
        Unauthorized. This error occurs if the authentication token is missing
        or invalid.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      description: >
        Use a Bearer token for authentication. Submit the token using the
        `Authorization`

        header: `Authorization: Bearer <token>`.
      scheme: bearer
    openId:
      type: oauth2
      flows:
        implicit:
          authorizationUrl: >-
            https://login.datalinks.com/realms/datalinks-realm/protocol/openid-connect/auth
          scopes:
            openid: openid

````